https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105077
--- Comment #3 from marshal <chumarshal at foxmail dot com> --- (In reply to Jonathan Wakely from comment #2) > I've added the first example there. The other two examples are exactly the > same scenario. > > *** This bug has been marked as a duplicate of bug 85795 *** But why "new int[negative];" throws std::bad_array_new_length as following case? I think "new int[negative]" and "new char[negative]" should both throw std::bad_array_new_length when "int negative = -1;". new int[negative] ========================================================================== #include <new> #include <stdexcept> int main() { int negative = -1; new int[negative]; return 0; } terminate called after throwing an instance of 'std::bad_array_new_length' what(): std::bad_array_new_length