This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]