As noted, C++ does not check that subscripts are within bounds. When an out-of-bounds reference is performed, the system completes it anyway. This will result in a fetch or a store at some location outside the array. Exactly where that lands depends on how the compiler has chosen to arrange memory, but it may be inside another variable, or inside some sort of system structure. If the operating system considers the address illegal, it will generally terminate the program. If not, the program will continue after changing or fetching some “random” variable. The resulting program behavior will be difficult to predict, and will vary from one system or compiler to another.
In this section are a few programs which perform illegal subscripts. Your results will almost certainly vary.