gcc/testsuite/g++.dg/ubsan/object-size-1.C
raw| 1 | // { dg-do compile } |
| 2 | // { dg-options "-Wpedantic -Wno-error=pedantic -fsanitize=undefined -fpermissive" } |
| 3 | |
| 4 | struct T |
| 5 | { |
| 6 | int c; char d[]; // { dg-warning "forbids flexible array member" } |
| 7 | }; |
| 8 | |
| 9 | struct T t = { 1, "a" }; // { dg-warning "initialization of a flexible array member " } |
| 10 | |
| 11 | int |
| 12 | baz (int i) |
| 13 | { |
| 14 | return t.d[i]; |
| 15 | } |
| 16 | |
| 17 | int |
| 18 | main (void) |
| 19 | { |
| 20 | baz (3); |
| 21 | } |