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

--- Comment #4 from Marat Radchenko <marat at slonopotamus dot org> ---
(In reply to Martin Liška from comment #3)
> It's caused by what was mentioned as 2) which transforms to:
> 
>   _6 = operator new [] (40);
>   __builtin_memset (_6, 0, 40);
>   operator delete [] (_6);
> 
> So there's a use of _6 and we probably can't remove it as memset can
> potentially access NULL pointer if operator new [] fails.

1. If operator new[] fails, there would be an exception instead of NULL, no?

2. It doesn't matter, you may guard accessing array with NULL check and still
observe described behavior.

What puzzles me the most is why removal of delete[] allows it to optimize.

Reply via email to