On 20 May 2015 at 09:27, Norbert Lange wrote: > I did not check the resulting assembly, but to me it seems gcc removes > anything thats not externally visibly in the destructor. > Which is kinda ironic because I understood its more or less > recommended at my employers to wipe your data in a destructor, helps > in debugging but its also considered defensive programming so the > object cant be misinterpreted as being "alive and valid". There is no way for a valid C++ program to tell whether the data was wiped in the destructor, because it is undefined behaviour to inspect the members of an object after its destructor runs, so the compiler is allowed to eliminate the writes. A correct program will not notice any difference whether the writes happen or not.