https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105077
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> --- It's the same. In both cases the compiler fails to check if the size expression is erroneous, and calls operator new(n) with a bad value that causes a std::bad_alloc exception. I'm both cases, the compiler should be checking the expression first and throwing the correct exception.