If int arr[5] is initialized but more then 5 elements are stored, then the extra element gets memory allocated in separate space. The old compilers like turbo reported crash as something got overwritten But that doesn't happen with Modern Compilers, so how do they deal with this issue?
Well, I moved to reopen so I guess I should write something of an answer:
It is impossible for a compiler (or It is impossible at compile time) to check for out-of-bounds access in some very common situations. For example, if an array index expression is read from an input file, or is the result of a computation using values only established during execution, then the out-of-bounds access happens long after the compiler has finished its work.
It is burdensome for a run-time system to check for out-of-bounds accesses. That is, every such check requires a calculation of what index is to be accessed, then a check that that index is in bounds; all that on top of 'normal' operations.
To see the impact of this take an array-operation-intensive program and compile it with both no run-time bounds checking, and with run-time bounds checking, and compare the execution speeds.
It seems that the widely-used languages which are compiled (eg C, C++, Fortran) all decided to not generate array-bounds-checking by default. But their compilers provide the option to generate code with array-bounds-checking.
(Historical diversion: I have a sneaking suspicion that in the early days C would have struggled to implement array-bounds-checking at run-time since it barely distinguished between arrays and pointers and I'm not sure it always knew what the array bounds were when the code executed. Fortran, on the other hand, uses a dope vector, which includes the size of the array. Perhaps someone more knowledgable than I could correct me on this.)
As to why one language defaults to not checking array bounds at run time, and another language defaults to checking, that's a matter for the language designers.
(Hysterical diversion: I think there were probably two reasons for not checking array bounds by default; one, the performance reason; two, these languages were hewn from stone by programmers who were real men who didn't need no stinking help from a machine to write code.)
And you can choose to work with such a language or not.