(root)/
gcc-13.2.0/
gcc/
testsuite/
c-c++-common/
hwasan/
use-after-free.c
       1  /* { dg-do run } */
       2  /* { dg-require-effective-target hwaddress_exec } */
       3  /* { dg-options "-fno-builtin-malloc -fno-builtin-free" } */
       4  /* { dg-shouldfail "hwasan" } */
       5  
       6  #ifdef __cplusplus
       7  extern "C" {
       8  #endif
       9  void *malloc (__SIZE_TYPE__);
      10  void free (void *);
      11  #ifdef __cplusplus
      12  }
      13  #endif
      14  
      15  int main() {
      16    char *x = (char*)malloc(10);
      17    free(x);
      18    return x[5];
      19  }
      20  
      21  
      22  /* { dg-output "HWAddressSanitizer: tag-mismatch on address 0x\[0-9a-f\]*.*" } */
      23  /* { dg-output "READ of size 1 at 0x\[0-9a-f\]* tags: \[\[:xdigit:\]\]\[\[:xdigit:\]\]/\[\[:xdigit:\]\]\[\[:xdigit:\]\] \\(ptr/mem\\) in thread T0.*" } */
      24  /* { dg-output "is located 5 bytes inside of 10-byte region.*" } */
      25  /* { dg-output "freed by thread T0 here:.*" } */
      26  /* { dg-output "#1\[^\n\r]*main\[^\n\r]*use-after-free.c:17.*" } */
      27  /* { dg-output "previously allocated here:.*" } */
      28  /* { dg-output "#1\[^\n\r]*main\[^\n\r]*use-after-free.c:16" } */