Debian Codegraph @

gcc/testsuite/c-c++-common/ubsan/overflow-sub-4.c

raw
1 /* { dg-do run } */
2 /* { dg-options "-fsanitize=signed-integer-overflow" } */
3
4 #define INT_MIN (-__INT_MAX__ - 1)
5
6 int
7 main ()
8 {
9 int x = INT_MIN;
10 int y = 0;
11 int z;
12 __asm__ volatile ("" : "+g" (y));
13 __asm__ volatile ("" : "+g" (x));
14 z = y - (-x);
15 __asm__ volatile ("" : "+g" (z));
16 }
17
18 /* { dg-output "negation of -2147483648 cannot be represented in type 'int'\[^\n\r]*; cast to an unsigned type to negate this value to itself\[^\n\r]*(\n|\r\n|\r)" } */
19 /* { dg-output "\[^\n\r]*signed integer overflow: 0 - -2147483648 cannot be represented in type 'int'" } */