https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103843
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|FIXED |INVALID --- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Georgii.Shagov from comment #3) > (In reply to Andrew Pinski from comment #2) > > This is undefined code. The object is officially not live after you call the > > deconstructor so GCC is able to remove the store from the deconstructor as > > being dead. > > I appreciate your reply. But this is confusing. The object was NOT released > (de-allocated). In essence Destructor is just a function. No, the destructor is not just a function in C++, it terminates the object being alive (not de-allocated though). You can then reuse the space for another object, either the same type or a different type by using the inplacement new. > Why the content of the class had been re-initialized? It was not re-initialized rather the store was removed. > IMU: there should be not such obvious difference between optimized and > non-optimized code why not, it is undefined code.