an rvalue reference question

John (Eljay) Love-Jensen eljay@adobe.com
Fri Jan 9 15:43:00 GMT 2009


Hi Chih-Long,

> blah z((blah())); // expecting calling blah::blah() and blah::blah(blah&&) but
got only blah::blah()

C++ allows this to be optimized, by eliding the copy constructor.  This
optimization is in the ISO 14882 specification.

This C++ optimization will occur even if you¹ve disabled GCC¹s optimizations
(-O0).

Try this flag to disable the C++ optimization:  -fno-elide-constructors

HTH,
<Eljay



More information about the Gcc-help mailing list