gcc/testsuite/c-c++-common/ubsan/pr87837.c
raw| 1 | /* PR sanitizer/87837 */ |
| 2 | /* { dg-do run } */ |
| 3 | /* { dg-options "-fsanitize=signed-integer-overflow -Wno-unused-variable" } */ |
| 4 | |
| 5 | int |
| 6 | foo (int n) |
| 7 | { |
| 8 | return n + __INT_MAX__ < n; |
| 9 | } |
| 10 | |
| 11 | int |
| 12 | main () |
| 13 | { |
| 14 | volatile int a = foo (1); |
| 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | /* { dg-output "signed integer overflow: 1 \\+ 2147483647 cannot be represented in type 'int'" } */ |