Undefined Behavior during pointer arithmetic on stack-allocated arrays
In C (ISO/IEC 9899), pointer arithmetic is permitted within the bounds of an array, including one element past the end. However, dereferencing a pointer that has moved beyond this boundary triggers Undefined Behavior (UB). A specific concern arises when compiler optimizations (such as -O2 or -O3 ) are applied. Because the compiler assumes UB never occurs, it