The Segmentation faults happens when you're trying to access non-paged memory block. Its an undefined behavior to access non initialized pointer, also accessing to memory with uninitialized subscript is undefined^2.
Undefined behavior may result in segmentation faults, may result data loss, may result papa noel comes out from your terminal !! or .... But in most cases, memory related undefined behavior issues result in segmentation faults or similar issues, but why you're not getting segmentation fault until dereferencing index you mentioned?
This is because you doesn't have initialized pointer array, the value stored in the memory which array occupied doesn't changed. Its totally by your chance that this variable holds an address which is paged on you applications virtual memory space. If you initialize it by zero or make it static or defining it as global variable you will definitely get an segmentation fault on its first dereference.
Some examples :
Manual initialization to NULL (zero)
{
int * ptr = NULL;
int index;
*ptr = 1; // segfault
*ptr[index] = 1; // may not segfault, based on uninitialized value stored in index
}
Static variables are initialized automatically
{
static int * ptr; // static variable (default initialized to 0)
*ptr = 1; // segfault
}
Global variables are initialized automatically, also
int * ptr; // global variable (default initialized to 0)
{
*ptr = 1; // segfault
}
Local storage variables in stack are uninitialized and keep the value on memory occupied untouched
{
int * ptr; // unintialized
*ptr = 1; // may segfault or may not
}