Debian Codegraph @

gcc/testsuite/c-c++-common/hwasan/bitfield-2.c

raw
1 /* { dg-do run } */
2 /* { dg-require-effective-target hwaddress_exec } */
3 /* { dg-shouldfail "hwasan" } */
4
5 /* Ensure that hwasan instruments bitfield accesses. */
6 struct A
7 {
8 /* Ensure the offset from the start of this struct to the bitfield we access
9 is large enough to be in a different tag. */
10 char base[16];
11 int : 4;
12 long x : 7;
13 };
14
15 int __attribute__ ((noinline, noclone))
16 f (void *p) {
17 return ((struct A *)p)->x;
18 }
19
20 int
21 main ()
22 {
23 char a = 0;
24 return f (&a);
25 }
26
27 /* { dg-output "HWAddressSanitizer: tag-mismatch on address 0x\[0-9a-f\]*.*" } */
28 /* { dg-output "READ of size 2 at 0x\[0-9a-f\]* tags: \[\[:xdigit:\]\]\[\[:xdigit:\]\]/00 \\(ptr/mem\\) in thread T0.*" } */
29 /* { dg-output "Address 0x\[0-9a-f\]* is located in stack of thread T0.*" } */
30 /* { dg-output "SUMMARY: HWAddressSanitizer: tag-mismatch \[^\n\]*.*" } */