gcc/testsuite/c-c++-common/ubsan/bounds-21.c
raw| 1 | /* PR sanitizer/109050 */ |
| 2 | /* { dg-do run } */ |
| 3 | /* { dg-options "-fsanitize=bounds -fno-sanitize-recover=all" } */ |
| 4 | |
| 5 | int i; |
| 6 | int foo (void) { return ++i; } |
| 7 | |
| 8 | int |
| 9 | main () |
| 10 | { |
| 11 | char a[10] = { }; |
| 12 | a[foo ()] = a[foo()] | 'a'; |
| 13 | if (i != 2) |
| 14 | __builtin_abort (); |
| 15 | a[foo()] |= 'a'; |
| 16 | if (i != 3) |
| 17 | __builtin_abort (); |
| 18 | } |