Is gcc allowed to eliminate writes in a destructor?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I know that using a class after a destructor is called is a nasty
thing and I already changed the code, but I am curious if gcc is
allowed by the standard to eliminate stores to member variables.

I had code similar to the following:

Destructor:
if (_pAlloc) free(_pAlloc);
_pAlloc = 0;
_SomeData = 0;

what happened was that I explicitly called the destructor for
"cleanup" in another method. The free was called, and after the
instance went out of scope it was called again with the same address.
It also reported "_SomeData" with its previous value, the member was
accessed shortly after the call to the destructor so it cant be
because of inlining + dead-code elimination.

Of course I now have that code in an own cleanup function and dont
call the destructor explicitely. But I am still surprised that gcc
kills those writes.




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux