Compiling the program below with MSVC 13.10.3077 for 80x86 using the
/GX /GZ /Ge options
#include <iostream>
using namespace std;
int main()
{
int ix[1];
ix[0] = 3;
cout << ix[0] << " " << ix[1] << endl;
}
produces a compilation warning
local variable 'ix' used without having been initialized
and output
3 -858993460
Is there an option that will cause the program to terminate at run
time
(preferably with an informative error message) when trying to access
an out-of-bounds array element?
If I add the line
ix[1] = 4;
before the cout the program prints '3 4' and then crashes. It would be
better if it crashed at the 'ix[1] = 4;' line.