Why warning on static local variables ... ?
Munagala V. S. Ramanath
ram@netcom.com
Mon Apr 20 18:01:00 GMT 1998
Alexandre Oliva <oliva@dcc.unicamp.br> writes:
[... stuff deleted ...]
>> The compiler is allowed to optimize away such copy-constructor call.
>> Instead of copy-constructing the object returned by Mul<B> into f3 and
>> f4, egcs arranges that Mul<B> constructs f3 and f4 directly, in-place.
To which I replied:
> This explains why A(&A) is _not_ called but does not explain why
> A(int) _is_ called instead in this case; as I see it, in the program
> output:
>
>A(int): val = 2560
>A(int): val = 2304
>Mul: &n = 0x22a0, n = 8
>A(int): val = 6553600
>Mul: &n = 0x22a0, n = 8
>A(int): val = 5308416
>f1 = 10, f3 = 25600, f2 = 9, f4 = 20736
>
> The first two calls of A(int) are for f1 and f2; then Mul is called
> for f3 but then we have _another_ call to A(int) followed by yet
> another call to A(int) after Mul is called for f4 which is what I
> still don't understand.
Oops, my mistake: the 3rd and 4th calls to the A(int) constructors are
from the return at the end of the Mul routine. Just didn't see it.
Sorry about that.
Ram
More information about the Gcc
mailing list