This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: Order of Object destruction
Hi Neophytos,
>When the call foo(a) is made the copy constructor is called and makes a
new object "z". This object "z" is supposed to be desposed off when it
goes out of scope.
Correct. And it does. Temporary object "z" goes out of scope at the
caller's semi-colon.
Returned object "b" also goes out of scope at the caller's semi-colon.
>I was asking which was supposed to be desposed of first "z" or "b"?
I think it is up to the discretion of the compiler's vendor whether it's a
LIFO object destruction at the semi-colon, or FIFO object destruction.
Sincerely,
--Eljay