Repository navigation
Conversation
|
xref: #6217 (comment) @sayed0200 could you please comment there? |
|
Replied on #6217: #6217 (comment). Short version: #6283 (merged yesterday) already fixes the optional/variant reference_wrapper cases from #5637, so the header change here is redundant. I've offered there to trim this PR to the two regression tests or close it, whichever you prefer. |
|
You can try the two regression tests if you think they add coverage. |
2fbc637 to
05a4673
Compare
|
Trimmed to tests only and rebased on master, header change dropped. I folded them into On the coverage question: both new assertions fail on |
Description
Closes #5637. Tests only, rebased on master.
#6283 fixed the underlying lifetime problem, and
std::optional/std::variantofstd::reference_wrapperis fixed on master as a side effect (thereference_wrappercaster propagatesrefers_to_caster). #6283 doesn't reference #5637 and its element-caster coverage usesconst char *for the optional/variant cases andstd::vector<std::reference_wrapper<const std::string>>for thereference_wrappercase, so the exact shapes from #5637 aren't exercised. This adds them totest_element_casters_kept_aliverather than as separate tests:load_optional_str_refandload_variant_str_refround-trip the existing heap-allocated string throughstd::optional<std::reference_wrapper<const std::string>>andstd::variant<int, std::reference_wrapper<const std::string>>, plus astatic_assertthatcast_refers_to_caster<std::reference_wrapper<const std::string>>is true (next to the existing one asserting it is false forstd::reference_wrapper<UserType>, which is the interesting contrast).Both assertions fail on the commit before #6283 and pass on master. Building the #5637 reproducer against
e770e5ed^returns a 200-character string with freed contents from both entry points; against master both round-trip intact.