Mail Archives: djgpp/1999/10/07/02:53:31
"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
- Raw text -