File: bug2935162.c

package info (click to toggle)
sdcc 4.2.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 105,232 kB
  • sloc: ansic: 956,095; cpp: 110,511; makefile: 59,314; sh: 29,875; asm: 17,178; perl: 12,136; yacc: 7,480; lisp: 1,672; python: 907; lex: 805; awk: 498; sed: 89
file content (62 lines) | stat: -rw-r--r-- 1,795 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
   bug2935162.c
*/

#pragma disable_warning 184

#include <testfwk.h>
#include <limits.h>

#if defined(__STDC_VERSION__)
# if (__STDC_VERSION__ >= 199901L)
#  define IS_C99
# endif
#endif

const float a[] =
{
    LONG_MAX,       /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09   */
    LONG_MIN,       /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09 ? */

    12345678901,    /* .byte #0x00,#0x00,#0x80,#0x4F ; +4.294967e+09   */
    -12345678901,   /* .byte #0x00,#0x00,#0x80,#0x3F ; +1.000000e+00 ? */

    12345678901L,   /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09   */
    -12345678901L,  /* .byte #0x00,#0x00,#0x00,#0xCF ; -2.147484e+09   */

    2147483647L,    /* .byte #0x00,#0x00,#0x00,#0x4F ; +2.147484e+09   */
#ifdef IS_C99
    -2147483648L,   /* .byte #0x00,#0x00,#0x00,#0xCF ; -2.147484e+09   */
#else
    -2147483647L-1, /* .byte #0x00,#0x00,#0x00,#0xCF ; -2.147484e+09   */
#endif
    ULONG_MAX,      /* .byte #0x00,#0x00,#0x80,#0x4F ; +4.294967e+09   */
    1.0,            /* .byte #0x00,#0x00,#0x80,#0x3F ; +1.000000e+00   */

    0.0,            /* .byte #0x00,#0x00,#0x00,#0x00 ; +0.000000e+00   */
    -0.0            /* .byte #0x00,#0x00,#0x00,#0x80 ; -0.000000e+00   */
};

void testBug (void)
{
#if !defined(__SDCC_pic16) && !defined(__SDCC_pdk14) // Lack of memory
    volatile int right;

    right = -120;

/* These first two tests assume LONG_MAX and LONG_MIN are 32-bit. This */
/* is not true for some 64-bit host compilers. Check SDCC only. */
#ifdef __SDCC
    ASSERT(a[0] > +2.1e9 && a[0] < +2.2e9);
    ASSERT(a[1] < -2.1e9 && a[1] > -2.2e9);
#endif
    ASSERT(a[2] > +2.1e9);
    ASSERT(a[3] < -2.1e9);
    ASSERT(a[4] > +2.1e9);
    ASSERT(a[5] < -2.1e9);
    ASSERT(a[6] > +2.1e9);
    ASSERT(a[7] < -2.1e9);
    ASSERT(a[8] > +4.2e9);
#endif
}