vendredi 29 août 2014

Program not Segfaulting when it should (C)


Vote count:

0




I'm running the program on Debian 7.5, i386. I'm trying to reproduce this code that is deliberately a segfault. For some reason however it's simply not segfaulting - but rather continuing execution until the end of the loop.



#include <stdio.h>

int main()
{
int array[5];
int i;

for (i=0; i<=255; i++)
{
array[i] = 10;
printf("%d\t\t%d\n", i, array[i]);
}
}


Compiled with



cc buffer.c


Produces the output



./a.out
0 10
1 10
2 10
3 10
4 10
10 1
11 10
12 10
13 10
14 10
15 10
....
255 10


Obviously this /should/ be segfaulting. I suspect there is some form of system or compile option enabled by default preventing it. Any idea what it is?


Thanks.



asked 59 secs ago

Peleus

115






Program not Segfaulting when it should (C)

Aucun commentaire:

Enregistrer un commentaire