Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-920922-1.c
blob2ff3efd013b6dbe95e2ab9c51afd1042803e543c
1 /*
2 920922-1.c from the execute part of the gcc torture suite.
3 */
5 #include <testfwk.h>
7 #ifdef __SDCC
8 #pragma std_c99
9 #endif
11 unsigned long*
12 f(unsigned long *p)
14 unsigned long a = (*p++) >> 24;
15 return p + a;
18 void
19 testTortureExecute (void)
21 // Incrementing pointers that far past the object is undefined behaviour and mcs51 indeed does the addition differently here (where it knows &x points to the stack) than in f.
22 #if !(defined(__SDCC_mcs51) && defined(__SDCC_STACK_AUTO)) && !defined(__SDCC_pdk14) && !defined(__SDCC_pdk15)
23 unsigned long x = 0x80000000UL;
24 if (f(&x) != &x + 0x81)
25 ASSERT(0);
26 return;
27 #endif