Mail Archives: djgpp/1999/10/14/22:02:31
In a previous article, weiqigao AT a DOT crl DOT com (Weiqi Gao) says:
>"Wendy E. McCaughrin" wrote:
>>
>> In a previous article, weiqigao AT a DOT crl DOT com (Weiqi Gao) says:
>>
>> >> TstCpy(Overflow(" I am a temporary\n")); // passing temp: no
>> >> // copy-ctor
>> >
>> >The object is constructed on TstCpy()'s stack.
>>
>> Well ... not exactly :) I single-stepped through the disassembled
>> code via FSDB and found that the object is ctor'd on main's stack,
>> not on TstCpy's. The argument passed to TstCpy() is always a ptr to
>> the temp, in both calls: that ptr is an address in main's stack-frame.
>
>You are right. Running it inside gdb reveals that the object is
>constructed inside what gdb described as main's frame. I guess that's
>dictated by the calling convention. But logically, the object lives
>with TstCpy(). For example, it is destructed when TstCpy() returns.
>Also, only TstCpy() can access the object, while main() cannot.
>
>--
>Weiqi Gao
>weiqigao AT a DOT crl DOT com
>
I should have read the info on options more carefully. Apparently, the
default action of `gpp' is _not_ to invoke the copy ctor in my circum-
stance (to init a temp), and this seems to be in accordance with the
current C++ standard. If one _always_ wants the copy ctor invoked, just
specify option: -fno-elide-constructors.
Thanks for all the help!
-- Wendy
- Raw text -