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++/12591] gcc accepts invalid code


PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

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



------- Additional Comments From hg211 at ural2 dot hszk dot bme dot hu  2003-10-13 10:46 -------
the standard says (in 8.5.3p5):

"If the initializer expression is an rvalue with T2 a class type and "cv1/T1" is
reference-compatible with "cv2/T2" the reference is bound in one of the
following ways (the choice is implementation defined):
  - The reference is bound to the object represented by the rvalue (see 3.10) or
to a sub-object within that object
  - A temporary of type "cv1/T2" [sic] is created, and a constructor is called
to copy the entire rvalue object into the temporary. The reference is bound to
the temporary or to a sub-object within the temporary

The constructor that would be used to make to copy shall be available whether or
not the copy is actually done."

I think it's about the copy constructor. If I'm not mistaken, the posted code is
invalid according to this quote (although I can't really see the rationale
behind it).


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