[Bug c++/55437] Non-const copy constructor causes error - even if not called
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Thu Nov 22 12:48:00 GMT 2012
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55437
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-11-22 12:48:09 UTC ---
The program is ill-formed.
String S = (char*)"Test";
is equivalent to
String S = String((char*)"Test");
which requires an accessible copy constructor (or in C++11 move constructor)
that takes an rvalue argument (i.e. temporary). A non-const reference cannot
bind to a temporary, so your copy constructor is not viable.
The copy constructor must be accessible and viable even if the copy is elided
and the copy constructor is not used.
You'll get the same error from any conforming C++ compiler.
More information about the Gcc-bugs
mailing list