[Bug c++/26471] no warning available when binding a temporary to a const reference member

pinskia at gcc dot gnu dot org gcc-bugzilla@gcc.gnu.org
Sat Feb 25 20:09:00 GMT 2006



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-02-25 19:57 -------
First:
  Y y(X());

that declares a function rather than a variable.
You want:
  Y y((X()));

Second, this is called life time and there is no way for GCC to know that
constructure's argument is used only for assigning to a variable in this.  And
there is no way to know for GCC to know that the argument assigning to this->x
comes from a temporary variable.  Unless you have IPA and then it would be cost
a lot of time to look.

And if the C++ books you have don't talk about life time of a temporary
variable, then they are not good C++ boks at all.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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



More information about the Gcc-bugs mailing list