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