struct / union in initializer, RFE #901.
[sdcc.git] / sdcc / support / regression / tests / bug2935162.c
blobf5c22dc0888d10a3e03d731fbb378c6ea70b10f8
1 /*
2 bug2935162.c
3 */
5 #pragma disable_warning 184
7 #include <testfwk.h>
8 #include <limits.h>
10 #if defined(__STDC_VERSION__)
11 # if (__STDC_VERSION__ >= 199901L)
12 # define IS_C99
13 # endif
14 #endif
16 const float a[] =
18 LONG_MAX, /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09 */
19 LONG_MIN, /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09 ? */
21 12345678901, /* .byte #0x00,#0x00,#0x80,#0x4F ; +4.294967e+09 */
22 -12345678901, /* .byte #0x00,#0x00,#0x80,#0x3F ; +1.000000e+00 ? */
24 12345678901L, /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09 */
25 -12345678901L, /* .byte #0x00,#0x00,#0x00,#0xCF ; -2.147484e+09 */
27 2147483647L, /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09 */
28 #ifdef IS_C99
29 -2147483648L, /* .byte #0x00,#0x00,#0x00,#0xCF ; -2.147484e+09 */
30 #else
31 -2147483647L-1, /* .byte #0x00,#0x00,#0x00,#0xCF ; -2.147484e+09 */
32 #endif
33 ULONG_MAX, /* .byte #0x00,#0x00,#0x80,#0x4F ; +4.294967e+09 */
34 1.0, /* .byte #0x00,#0x00,#0x80,#0x3F ; +1.000000e+00 */
36 0.0, /* .byte #0x00,#0x00,#0x00,#0x00 ; +0.000000e+00 */
37 -0.0 /* .byte #0x00,#0x00,#0x00,#0x80 ; -0.000000e+00 */
40 void testBug (void)
42 #if !defined(__SDCC_pic16) && !defined(__SDCC_pdk14) // Lack of memory
43 volatile int right;
45 right = -120;
47 /* These first two tests assume LONG_MAX and LONG_MIN are 32-bit. This */
48 /* is not true for some 64-bit host compilers. Check SDCC only. */
49 #ifdef __SDCC
50 ASSERT(a[0] > +2.1e9 && a[0] < +2.2e9);
51 ASSERT(a[1] < -2.1e9 && a[1] > -2.2e9);
52 #endif
53 ASSERT(a[2] > +2.1e9);
54 ASSERT(a[3] < -2.1e9);
55 ASSERT(a[4] > +2.1e9);
56 ASSERT(a[5] < -2.1e9);
57 ASSERT(a[6] > +2.1e9);
58 ASSERT(a[7] < -2.1e9);
59 ASSERT(a[8] > +4.2e9);
60 #endif