2 /* Check basic stack overflow detection.
4 It's difficult to get consistent behaviour across all platforms.
5 For example, x86 w/ gcc-4.3.1 gives
7 Expected: stack array "a" in frame 2 back from here
8 Actual: stack array "beforea" in frame 2 back from here
10 whereas amd64 w/ gcc-4.3.1 gives
12 Expected: stack array "a" in frame 2 back from here
15 This happens because on x86 the arrays are placed on the
16 stack without holes in between, but not so for amd64. I don't
23 __attribute__((noinline
)) void foo ( long* sa
, int n
)
26 for (i
= 0; i
< n
; i
++)
30 __attribute__((noinline
)) void bar ( long* sa
, int n
)
41 bar(a
, 7+1); /* generates error */
42 bar(a
, 7+0); /* generates no error */
43 for (i
= 0; i
< 7+1; i
++) {
49 sprintf(buf
, "%d", 123456789);
50 return 1 & ((a
[4] + beforea
[1] + aftera
[1] + beforebuf
[1]
51 + buf
[2] + afterbuf
[3]) / 100000) ;