copy ctor not called
Jeroen Wijnhout
jeroen@wijnhout.com
Thu Jul 7 11:45:00 GMT 2005
> Hi Jeroen,
>
>>To me this says, that I -fno-elide-constructors should be the default
>> behavior. Which it isn't (at least for gcc 3.3.4).
>
> Due to the design and evolution of C++, your expectation that
> "-fno-elide-constructors should be the default behavior" is not the case.
>
> I can understand where a person would expect that to be the situation.
>
> However, C++ standard has the elide "optimization" be the default behavior
> for proper C++, and the -fno-elide-constructors is a non-compliant
> pessimization.
Hmm, I have the 2005 edition of "C++ Primer", which I kind of trusted
because one of the authors was involved in the C++ ISO standards
committee. They write
in section 13.1 (page 477):
"Copy-initialization always involves the copy constructor".
According to your statement they are wrong.
> Moreso, you've touched up the (surprising?) requirement for the copy
> constructor to be public.
>
> These C++ anachronisms are due in large part to the design and evolution
> of C++. They are legacy warts.
Thanks for your explanation.
best,
Jeroen
More information about the Gcc-help
mailing list