2 /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */
6 #define SCHAR_MAX __SCHAR_MAX__
7 #define SHRT_MAX __SHRT_MAX__
8 #define INT_MAX __INT_MAX__
9 #define INT_MIN (-__INT_MAX__ - 1)
11 void __attribute__((noinline
,noclone
))
21 fputs ("UBSAN TEST START\n", stderr
);
23 #if __INT_MAX__ == 2147483647
24 /* Here, nothing should fail. */
25 volatile int j
= INT_MAX
;
27 volatile int k
= j
+ i
;
28 check (k
, 2147483646);
30 check (k
, 2147483646);
32 check (j
, 2147483646);
37 check (k
, -2147483647);
39 check (k
, -2147483647);
41 check (j
, -2147483647);
44 /* Test integer promotion. */
45 #if __SCHAR_MAX__ == 127
46 volatile signed char a
= SCHAR_MAX
;
47 volatile signed char b
= 1;
48 volatile signed char c
= a
+ b
;
54 #if __SHRT_MAX__ == 32767
55 volatile short d
= SHRT_MAX
;
57 volatile short f
= d
+ e
;
63 fputs ("UBSAN TEST END\n", stderr
);
67 /* { dg-output "UBSAN TEST START(\n|\r\n|\r)UBSAN TEST END" } */