This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Copy constructor: is this a bug?
- From: me22 <me22 dot ca at gmail dot com>
- To: Michael Tsang <miklcct at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sun, 1 Nov 2009 00:06:03 -0400
- Subject: Re: Copy constructor: is this a bug?
- References: <200910312221.54155.miklcct@gmail.com>
2009/10/31 Michael Tsang <miklcct@gmail.com>:
>
> Â Â Â ÂTest(const Test &x): count(x.count+1) {
> Â Â Â Â}
>
> Actual result:
>
> 0
> 0
> 0
>
Looks like legit copy constructor elision to me. This is a good thing
for anything with value-semantic copy constructors (as they all should
be), but if you have classes that do strange things (like your
example), check out -fno-elide-constructors