https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92332
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- two things, One is you are violating C++ aliasing rules I think. Second is after "operator new", the value that is contained in the pointer is undefined/unspecified. NOTE in C++2a (or c++20), there is an operator new which has the property of the value is kept defined. (BUT GCC Does not implement that yet).