Debian Codegraph @

gcc/testsuite/c-c++-common/ubsan/pr109107-3.c

raw
1 /* PR sanitizer/109107 */
2 /* { dg-do run { target int32 } } */
3 /* { dg-options "-fsanitize=signed-integer-overflow" } */
4
5 #define INT_MIN (-__INT_MAX__ - 1)
6 const int a = INT_MIN;
7 const int b = 40;
8 int d = 1;
9
10 __attribute__((noipa)) int
11 foo ()
12 {
13 int c = a - d + (int) (short) b;
14 return c;
15 }
16
17 int
18 main ()
19 {
20 foo ();
21 return 0;
22 }
23
24 /* { dg-output "signed integer overflow: -2147483648 - 1 cannot be represented in type 'int'\[^\n\r]*(\n|\r\n|\r)" } */
25 /* { dg-output "\[^\n\r]*signed integer overflow: 2147483647 \\+ 40 cannot be represented in type 'int'" } */