This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12591] gcc accepts invalid code
- From: "hg211 at ural2 dot hszk dot bme dot hu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Oct 2003 10:46:35 -0000
- Subject: [Bug c++/12591] gcc accepts invalid code
- References: <20031012204520.12591.hg211@ural2.hszk.bme.hu>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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).