gcc/testsuite/c-c++-common/asan/bitfield-1.c
raw| 1 | /* Check that Asan correctly instruments bitfields with non-round size. */ |
| 2 | |
| 3 | /* { dg-do run } */ |
| 4 | /* { dg-shouldfail "asan" } */ |
| 5 | |
| 6 | struct A |
| 7 | { |
| 8 | char base; |
| 9 | int : 4; |
| 10 | long x : 7; |
| 11 | }; |
| 12 | |
| 13 | int __attribute__ ((noinline, noclone)) |
| 14 | f (void *p) { |
| 15 | return ((struct A *)p)->x; |
| 16 | } |
| 17 | |
| 18 | int |
| 19 | main () |
| 20 | { |
| 21 | char a = 0; |
| 22 | return f (&a); |
| 23 | } |
| 24 | |
| 25 | /* { dg-output "ERROR: AddressSanitizer: stack-buffer-overflow" } */ |