gcc/testsuite/gcc.dg/Warray-bounds-26.c
raw| 1 | /* { dg-do compile } */ |
| 2 | /* { dg-options "-O2 -Warray-bounds" } */ |
| 3 | |
| 4 | struct Rec { |
| 5 | unsigned char data[1]; // actually variable length |
| 6 | }; |
| 7 | |
| 8 | union U { |
| 9 | unsigned char buf[42]; |
| 10 | struct Rec rec; |
| 11 | }; |
| 12 | |
| 13 | int Load() |
| 14 | { |
| 15 | union U u; |
| 16 | return u.rec.data[1]; /* { dg-bogus "array bound" } */ |
| 17 | } |