Pick three bugfixes from next branch to trunk for inclusion in 4.5.0 RC2, as discusse...
[sdcc.git] / sdcc / support / regression / tests / bug-3391.c
blob2383c671c79d2be3cfe0d0d99d3c4c2a1c904bb2
1 /*
2 bug-3166.c
3 Due to a check in SDCCval.c using double instead of long long (thus losing precision, 0x8000000000000000 was given the type of signed long long instead of unsigned long long.
4 */
6 #include <testfwk.h>
8 #include <limits.h>
10 #define IS_ULL(x) _Generic((x), unsigned long long: 1, default: 0)
11 #define IS_UL(x) _Generic((x), unsigned long: 1, default: 0)
13 void testBug(void)
15 #if (LLONG_MAX <= 0x7fffffffffffffffLL)
16 ASSERT( IS_ULL(0x8000000000000000ll)); // Bug triggered here.
17 ASSERT(!IS_ULL(0x7fffffffffffffffll));
18 #endif
19 ASSERT(!IS_ULL(0x0000000080000000ll));
21 #if (LONG_MAX <= 0x7fffffffL)
22 ASSERT( IS_UL(0x80000000l));
23 ASSERT(!IS_UL(0x7fffffffl));
24 #endif
25 ASSERT(!IS_UL(0x00008000l));