This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/51270] missed warning about returning reference to temporary


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=51270

--- Comment #6 from Michiel De Wilde <michiel_dewilde at agilent dot com> 2011-11-22 18:20:44 UTC ---
Hi Jonathan, thanks for the quick analysis.

I did not realize that "char * &" and "char const * &" are not
reference-compatible, leading to a temporary being introduced when initializing
a "char const * const &" reference from a "char * &".

Therefore this is not a true gcc bug.

It would be nice though to have a warning for this case, i.e. when only the
different constnesses after pointer dereferencing are responsible for
temporaries being created for const lvalue initializations from other lvalues.
I understand this may be difficult.
Improved tracking of the reference to the temporary would also be nice.

Thanks,

Michiel


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]