Require target lra in gcc.dg/pr108095.c
[official-gcc.git] / gcc / testsuite / c-c++-common / hwasan / asan-pr70541.c
blobbe534dfd2319547d50f908306294027563b2829b
1 /* { dg-do run } */
2 /* { dg-require-effective-target hwaddress_exec } */
3 /* { dg-options "-fno-builtin-malloc -fno-builtin-free" } */
4 /* { dg-skip-if "" { *-*-* } { "*" } { "-O0" } } */
5 /* { dg-shouldfail "hwasan" } */
7 #include <stdio.h>
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 extern void *malloc (__SIZE_TYPE__);
12 extern void free (void *);
13 #ifdef __cplusplus
15 #endif
17 struct Simple {
18 int value;
21 int f(struct Simple simple) {
22 return simple.value;
25 int main() {
26 struct Simple *psimple = (struct Simple *) malloc(sizeof(struct Simple));
27 psimple->value = 42;
28 free(psimple);
29 printf("%d\n", f(*psimple));
30 return 0;
33 /* { dg-output "HWAddressSanitizer: tag-mismatch on address 0x\[0-9a-f\]*.*" } */
34 /* { dg-output "READ of size 4 at 0x\[0-9a-f\]* tags: \[\[:xdigit:\]\]\[\[:xdigit:\]\]/\[\[:xdigit:\]\]\[\[:xdigit:\]\] \\(ptr/mem\\) in thread T0.*" } */
35 /* { dg-output "freed by thread T0 here:.*" } */
36 /* { dg-output "previously allocated by thread T0 here:" } */