Order of Object destruction

Eljay Love-Jensen eljay@adobe.com
Fri May 23 13:56:00 GMT 2003


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



More information about the Gcc-help mailing list