If we call "new T[0]", where T is a class with DTOR,
we'll allocate a 8 byte chunk and store the pointer to the end of this chunk.
% cat leak0.cc
#include <stdio.h>
struct T {
~T() { printf("~T\n"); }
};
T *t;
int main(int argc, char **argv) {
t = new T[argc - 1];
}
% clang++ -g leak0.cc -fsanitize=address && ASAN_OPTIONS=detect_leaks=1 ./a.out
=================================================================
==18656==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 8 byte(s) in 1 object(s) allocated from:
#0 0x4558b6 in operator new[](unsigned long) /home/kcc/llvm/projects/compiler-rt/lib/asan/asan_new_delete.cc:56
#1 0x46c655 in main /home/kcc/tmp/leak0.cc:9
#2 0x7f5a8fa6476c in __libc_start_main /build/buildd/eglibc-2.15/csu/libc-start.c:226
SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).
%
Original issue reported on code.google.com by konstant...@gmail.com on 10 Jan 2014 at 9:14
Original issue reported on code.google.com by
konstant...@gmail.com
on 10 Jan 2014 at 9:14