struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug-3641.c
blobe1baf2e6ea3421d79ab97e32e907003abade3c93
1 /* bug-3641.c
2 The hc08/s08 backend omitted the least-significant byte in an assignment of a literal to a local 24-bit variable, depending on which registers it resided in.
3 */
5 #include <testfwk.h>
7 #include <stdint.h>
9 #if __SDCC_BITINT_MAXWIDTH >= 32 // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
10 // In both assignments to i, the least-significant byte gets omitted.
11 void loopm2(unsigned char *a)
13 for (unsigned _BitInt(24) i = (1ul << 20); i < (1ul << 20) + 1; i = (1ul << 20) + 1)
14 a[i - (1ul << 20)] = 1;
16 #endif
18 void
19 testBug(void)
21 #if __SDCC_BITINT_MAXWIDTH >= 32 // TODO: When we can regression-test in --std-c23 mode, use the standard macro from limits.h instead!
22 char c = 0;
23 loopm2(&c);
24 #ifndef __SDCC_pdk15 // Bug #3643.
25 ASSERT(c == 1);
26 #endif
27 #endif