[Bug c++/66717] In variable declaration, decltype incorrectly deduces return type of function returning const reference to int

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Jul 1 10:16:00 GMT 2015


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

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2015-07-01
     Ever confirmed|0                           |1

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> ---
The static_assert suggests the deduction is correct, so I'm not sure, but the
problem could just be a misleading diagnostic.

Trying to initialize the const int& could be attempting to create a temporary
of type int (which the reference could bind to) and then giving an error
complaining that the creation of that temporary fails.

Presumably it tries the same thing in the string case, but when creating a
string temporary fails it gives a useful error, not an error about an unwanted
side-effect.



More information about the Gcc-bugs mailing list