You will get this for int a[-1] :
prog.cpp: In function 'int main()': prog.cpp:4: error: size of array 'b' is negative
And this is for int* a = new int[-1] (runtime error):
terminate called after throwing an instance of 'std::bad_alloc' what(): std::bad_alloc
alestanis
source share