https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117246

--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Andrew Pinski from comment #1)
> https://gcc.gnu.org/onlinedocs/gcc-14.2.0/gcc/Optimize-Options.html#index-
> flifetime-dse
> 
> `To preserve stores before the constructor starts (e.g. because your
> operator new clears the object storage) but still treat the object as dead
> after the destructor, you can use -flifetime-dse=1.`

The code is not valid C++ though, so should be fixed instead of disabling
optimizations.
https://gcc.gnu.org/gcc-6/porting_to.html#flifetime-dse

operator new is for allocating memory, not initializing members. A constructor
is for initializing members.

Reply via email to