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

--- Comment #5 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Dávid Bolvanský from comment #4)
> But GCC 5.5 could remove one malloc-free pair
> https://godbolt.org/z/fDJZs0
> 
> New optimization in gcc 6 actually made the code worse..

But the code is undefined.  the old GCC did not take into account that fact and
was able to optimize it away.  In new GCC it takes into account that before the
constructor is run, the object values is undefined.

Plus this change is actually documented in the porting to guide of GCC 6:
https://gcc.gnu.org/gcc-6/porting_to.html#flifetime-dse

With almost your exact testcase.

Reply via email to