struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3470.c
blobb1d56f1b25f510ac23fe39fb62cf75e23b6e7e7f
1 /* bug-3459.c
2 A bug in CSE resulted in a used temporary holding the address of a struct parameter being optimized out during loop optimizations.
3 This was visible as a crash during code generation.
4 The testcase is manually simplified code originally created by csmith.
5 */
7 #include <testfwk.h>
9 #pragma disable_warning 85
10 #pragma disable_warning 94
11 #pragma disable_warning 158
13 #include <stdint.h>
15 #if !defined(__SDCC_pdk13) && !defined(__SDCC_pdk14) // Lack of memory
16 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk15) && !defined(__SDCC_ds390) // Remaining aspects of bug
17 struct S0 {
18 signed f0 : 3;
19 signed f1 : 12;
22 static int32_t g_2 = 0x09C3FBB4L;
23 static int32_t g_22 = 0xD9E62B56L;
24 static uint64_t g_33 = 1UL;
25 static volatile int32_t g_38 = (-9L);
26 static volatile int32_t *g_37[1] = {&g_38};
27 static volatile int32_t **g_36 = &g_37[0];
28 static volatile int32_t *** volatile g_39[2] = {&g_36,&g_36};
29 static volatile uint8_t g_53 = 0xA6L;
31 static uint64_t func_1(void);
32 int32_t func_5(const int64_t p_6, int32_t p_7, uint32_t p_8, struct S0 p_9, int8_t p_10);
34 static uint64_t func_1(void)
36 const int8_t l_11 = (-2L);
37 int32_t l_41 = 0x3EE1E161L;
38 int32_t l_52[2];
39 int i;
40 for (i = 0; i < 2; i++)
41 l_52[i] = 0x33B75CABL;
42 for (g_2 = 0; (g_2 != (-23)); g_2--)
44 int32_t l_12 = 0x58EDFE01L;
45 struct S0 l_13 = {1,18};
46 int32_t *l_42 = &g_22;
47 if (func_5(l_11, g_2, l_12, l_13, g_2))
49 int32_t *l_31[2][1];
50 int i, j;
51 for (i = 0; i < 2; i++)
53 for (j = 0; j < 1; j++)
54 l_31[i][j] = &g_22;
56 --g_33;
58 else
60 volatile int32_t ***l_40 = &g_36;
61 (*l_40) = g_36;
62 (**g_36) = (**g_36);
64 (*l_42) ^= (((l_41 |= (l_11 >= 0xB0L)) != l_11) ^ g_38);
67 return l_52[0];
70 int32_t func_5(const int64_t p_6, int32_t p_7, uint32_t p_8, struct S0 p_9, int8_t p_10)
72 return 0;
74 #endif
75 #endif
77 void
78 testBug (void)
80 #if !defined( __SDCC_pdk13) && !defined( __SDCC_pdk14) // Lack of memory
81 #if !defined(__SDCC_mcs51) && !defined(__SDCC_pdk15) && !defined(__SDCC_ds390) // Remaining aspects of bug
82 func_1();
83 #endif
84 #endif