https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93862

--- Comment #6 from Will Wray <wjwray at gmail dot com> ---
Thanks for the quick work.
However, I'm not sure that (2) and (3) _are_ invalid.

(Sorry, I didn't have time to follow the email thread).
I should have provided this link to an exchange with Richard Smith.
I'd waited for his response before filing the bug. He says:
"In both cases, it's valid to use static_cast to recover the original type."

https://cpplang.slack.com/archives/C2PQKRWJU/p1579186047347300

zygoloid  Feb 20
Lifetime extension applies; the lifetime extension rules don't care about
qualification conversions. Another example: const int *const &r =
static_cast<int*&&>(nullptr); performs lifetime extension even though the type
of the temporary object (int*) has been lost (mutability-erased) in the
reference binding.

zygoloid  Feb 20
In both cases, it's valid to use static_cast to recover the original type.

willw  Feb 20
Thanks for the confirmation. That makes sense.

willw  Feb 21
I filed the gcc bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93862

Reply via email to