[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Copy constructor, or assingment operator not being called.
From: |
Thomas Maeder |
Subject: |
Re: Copy constructor, or assingment operator not being called. |
Date: |
Thu, 21 Oct 2004 19:18:41 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Security Through Obscurity, linux) |
manuel@sisdetec.es (manu) writes:
> It should make an a object, and then a copy to pass it as return
> value, but it doesn't.
>
> Output is:
>
> Creating a with 1 value.
> Value: 1
> _s_count=1
> Destroying a.
>
> It should be at least 2 objects, may be even 3. (In function 1,
> parameter 2 and assignment in main 3)
>
> Am I wrong? Am I missing something?
You are missing that a compiler is entitled to optimize these copies away.
It has to check the availability of the copy constructor, but it needn't
generate code that calls it.