197ccf6b8SFangrui Song // Regression test: pointers to self should not confuse LSan into thinking the 297ccf6b8SFangrui Song // object is indirectly leaked. Only external pointers count. 397ccf6b8SFangrui Song // RUN: %clangxx_lsan %s -o %t 4*d08e5d4cSClemens Wasser // RUN: %env_lsan_opts="report_objects=1:use_registers=0:use_stacks=0" not %run %t 2>&1 | FileCheck %s 597ccf6b8SFangrui Song 697ccf6b8SFangrui Song #include <stdio.h> 797ccf6b8SFangrui Song #include <stdlib.h> 897ccf6b8SFangrui Song #include "sanitizer_common/print_address.h" 997ccf6b8SFangrui Song main()1097ccf6b8SFangrui Songint main() { 1197ccf6b8SFangrui Song void *p = malloc(1337); 1297ccf6b8SFangrui Song *reinterpret_cast<void **>(p) = p; 1397ccf6b8SFangrui Song print_address("Test alloc: ", 1, p); 1497ccf6b8SFangrui Song } 1597ccf6b8SFangrui Song // CHECK: Test alloc: [[ADDR:0x[0-9,a-f]+]] 1697ccf6b8SFangrui Song // CHECK: LeakSanitizer: detected memory leaks 1797ccf6b8SFangrui Song // CHECK: [[ADDR]] (1337 bytes) 1897ccf6b8SFangrui Song // CHECK: SUMMARY: {{(Leak|Address)}}Sanitizer: 19