struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / gcc-torture-execute-20051104-1.c
blob9436bdfe0c28a32735acd602d97bb638e43a234b
1 /*
2 20051104-1.c from the execute part of the gcc torture suite.
3 */
5 /*
6 Optimization transformed 'if (cond) *ptr = 0;' into '*ptr = (cond) ? 0 : *ptr;'
7 and thus wrote to literal string which gives undefined behavior
8 or in the case of gcc a segmentation fault.
9 The pointer being a plain char* and assigned a literal string is essential to the bug.
10 Therefor warning 196 must be disabled.
13 #include <testfwk.h>
15 #ifdef __SDCC
16 #pragma std_c99
17 #pragma disable_warning 196
18 #endif
20 /* PR rtl-optimization/23567 */
22 struct
24 int len;
25 char *name;
26 } s;
28 void
29 testTortureExecute (void)
31 s.len = 0;
32 s.name = "";
33 if (s.name [s.len] != 0)
34 s.name [s.len] = 0;
35 return;