I wrote the following piece of code to allocate memory for an array:
try {
int n = 0;
cin >> n;
double *temp = new double[n];
...
}
catch(exception& e) {
cout << "Standard exception: " << e.what() << endl;
exit(1);
}
Of course I'm checking n for negative values etc. but when I enter some large Number over 536*(10^6) I'm not getting a bad-alloc exception but a "Invalid Allocation Size: 4294967295 Bytes" Crash.
E.G. I enter n = 536*(10^6) --> bad-alloc exception I enter n = 537*(10^6) --> Invalid Allocation Size: 4294967295 Bytes --> Crash
Any ideas why this is happening?