Although this is technically undefined behavior, in practice no native architecture checks for out-of-bounds memory access at a finer granularity than the size of a word. So while garbage past the terminator may end up being read, the result will not be a crash.
More Related Contents:
- function returns address of local variable, but it still compile in c, why?
- (Why) is using an uninitialized variable undefined behavior?
- Can we change the value of an object defined with const through pointers?
- Is accessing a global array outside its bound undefined behavior?
- How undefined is undefined behavior?
- Is the behaviour of casting a negative double to unsigned int defined in the C standard? Different behaviour on ARM vs. x86
- When is casting between pointer types not undefined behavior in C?
- Is the output of printf (“%d %d”, c++, c); also undefined?
- What is Undefined Behaviour in C? [duplicate]
- 32 bit unsigned multiply on 64 bit causing undefined behavior?
- In C99, is f()+g() undefined or merely unspecified?
- Unspecified, undefined and implementation defined behavior WIKI for C
- Sequence points and side effects in C
- Why does char* cause undefined behaviour while char[] doesn’t?
- How to implement memmove in standard C without an intermediate copy?
- Is this undefined C behaviour?
- C – function returning a pointer to a local variable
- Is while(1); undefined behavior in C?
- Order of evaluation of arguments in function calling?
- C code with undefined results, compiler generates invalid code (with -O3)
- printf() with no arguments in C compiles fine. how?
- When is it valid to access a pointer to a “dead” object?
- Is it Undefined Behaviour to cast away the constness of a function parameter?
- C – is an indeterminate value indeterminable?
- Does ctype.h still require unsigned char?
- Why is undefined behaviour allowed in C
- Cast T[][] to T*
- Turbo C++: Why does printf print expected values, when no variables are passed to it?
- 2D Array indexing – undefined behavior?
- Uninitialized variable in C [duplicate]