You are viewing a single comment's thread. Return to all comments →
you will get an exception
If it's in C/C++, there's no array bounds checking, so there would not be an exception. But as others have said, it's still not correct. It will read from the memory location just before the start of the array. If by chance or due to the specific implementation of the compiler, that memory location happens to hold 0, it will work. On a different system, or with a different compiler, or with different conditions, that memory location may have different contents that change the result.
There may not be an exception. It can still seg fault.
It's wrong in any case.