I am having a odd issue running scientific linux in VirtualBox when compiling this:
#include <stdlib.h>
#include <stdio.h>
int main(void) {
    int *arr;
    arr = malloc(sizeof(int)*3);
    arr[6]=5;
    printf("%d", arr[6]);
    return 0;
}
my expectation is that I should get garbage when printing out this arr[6] because I have not allocated enough memory for that space.
However, I will compile it with gcc
gcc main.c -o MainTest
then it will output
5
I may be a bit confused but shouldn't the number be some random number
 
     
    