https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81420
Jason Merrill <jason at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution|--- |FIXED
Target Milestone|--- |8.2
--- Comment #8 from Jason Merrill <jason at gcc dot gnu.org> ---
(In reply to Ion Lupascu from comment #7)
> Not really, The issue still persists
>
> std::optional<double> getValue(){
...
> const double &v = *getValue();
...
> const double &v = getValue()->v;
Neither of these bind the reference to a prvalue; std::optional operator*
returns a reference, and operator-> returns a pointer, so in both cases we're
binding the reference to an xvalue, and GCC is correct not to extend the
temporary.
Fixed in 8.2.