[Bug c++/40655] The copy constructor is not needed but GCC (C++) don't let me to initialize my object instance!

jwakely dot gcc at gmail dot com gcc-bugzilla@gcc.gnu.org
Mon Jul 6 17:34:00 GMT 2009



------- Comment #4 from jwakely dot gcc at gmail dot com  2009-07-06 17:34 -------
See 8.5 [dcl.init] paragraph 12

The initialization that occurs in argument passing, function return, throwing
an exception (15.1), handling an exception (15.3), and brace-enclosed
initializer lists (8.5.1) is called copy-initialization and is equivalent to
the form
T x = a;

and 12.8 [class.copy] paragraphs 14 and 15

A program is ill-formed if the copy constructor or the copy assignment operator
for an object is implicitly used and the special member function is not
accessible
...
When certain criteria are met, an implementation is allowed to omit the copy
construction of a class object, even if the copy constructor and/or destructor
for the object have side effects.

Your code is invalid, this is not a bug in GCC.


-- 


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



More information about the Gcc-bugs mailing list