| 1 |
/* { dg-do run { target int32 } } */ |
| 2 |
/* { dg-shouldfail "ubsan" } */ |
| 3 |
/* With optimization we constant fold and diagnose the overflow and do |
| 4 |
not sanitize anything. */ |
| 5 |
/* { dg-skip-if "" { *-*-* } { "*" } { ! "-O0" } } */ |
| 6 |
/* { dg-options "-fsanitize=undefined -fno-sanitize-recover=undefined" } */ |
| 7 |
|
| 8 |
int a; |
| 9 |
const int b = 44514; |
| 10 |
int *c = &a; |
| 11 |
|
| 12 |
int main () |
| 13 |
{ |
| 14 |
*c = 65526 * b / 6; |
| 15 |
return 0; |
| 16 |
} |
| 17 |
|
| 18 |
/* { dg-output "signed integer overflow: 44514 \\* 65526 cannot be represented in type 'int'" } */ |