I am trying to set the value of an unassigned memory location in order to get an exception, so what I have been doing is taking an integer (with a valid memory location) getting its address, adding 4 to it (to go the the next integer hopefully), dereferencing it and assigning it a value (1):
int i = 20;
(*((&i) + 4)) = 1;
This line is throwing an error saying that
CL.exe exited with code 2.
Is this a compiler bug?
Note: I am using the Microsoft C++ compiler on VS 2019.
EDIT: here is a screen shot of the dark side of the code (added in order to make it clear that this is the only error that I get):
I just wanted to know if this was a compiler bug since it was not showing up an appropriate error message.