Is gcc allowed to eliminate writes in a destructor?

Jonathan Wakely jwakely.gcc@gmail.com
Wed May 20 09:59:00 GMT 2015


On 20 May 2015 at 10:49, Avi Kivity wrote:
> He's talking about an incorrect program.  Wiping the object can detect a
> use-after-free or otherwise cause the program to crash earlier rather than
> later.

I know. My point is that the compiler is always allowed to perform
optimisations that are invisible to correct programs.

An incorrect program has undefined behaviour, and not seeing those
writes happen is one possible way that undefined behaviour can express
itself.



More information about the Gcc-help mailing list