https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110137
--- Comment #16 from user202729 <user202729 at protonmail dot com> --- Hi, I tried to implement patches that fix the two issues mentioned. Comments would be appreciated. 1. The operator new flag with many of the mentioned issues fixed: https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654145.html Although I'm not entirely sure what to do with the link-time optimization part. 2. The optimization to move the definition to right before the use: https://gcc.gnu.org/pipermail/gcc-patches/2024-June/654700.html . As explained, I'm not sure if implementing it in the RTL phase; nevertheless, reviews and suggestions to improve the code, or explain how to implement it in GIMPLE phase would be appreciated. ------ Regarding the example code in the previous comment, it appears that the current analyzer is smart enough to do the optimization when the call to operator new is replaced by a pure function (curiously enough, it does not need to assume the returned value does not alias because both the values are 0). So, yes it should be possible (although I haven't test it with the proposed patch).