You get only a segmentation error when you are outside the memory area accessible to your program, while being outside the defined array does not mean that you are outside the memory area of ββyour program. However, it may read unnecessary data and / or overwrite other parts of your program data, or in some cases even your program code, which may lead to buffer overflows.
Of course, if your array is at the very beginning or end of your memory area, then you will get a segmentation error. Where the array falls into memory is determined by the compiler and linker. Similarly, when you are out of the range of your array. Try for example char_freq[2^31] This will probably give you a segmentation error.
source share