# gcc -v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/lto-wrapper Target: x86_64--netbsd Configured with: /usr/src/tools/gcc/../../external/gpl3/gcc/dist/configure --target=x86_64--netbsd --enable-long-long --enable-threads --with-bugurl=http://www.NetBSD.org/support/send-pr.html --with-pkgversion='NetBSD nb1 20200907' --with-system-zlib --without-isl --enable-__cxa_atexit --enable-libstdcxx-time=rt --enable-libstdcxx-threads --with-diagnostics-color=auto-if-env --with-tune=nocona --with-default-libstdcxx-abi=new --with-mpc-lib=/var/obj/mknative/amd64-x86_64/usr/src/external/lgpl3/mpc/lib/libmpc --with-mpfr-lib=/var/obj/mknative/amd64-x86_64/usr/src/external/lgpl3/mpfr/lib/libmpfr --with-gmp-lib=/var/obj/mknative/amd64-x86_64/usr/src/external/lgpl3/gmp/lib/libgmp --with-mpc-include=/usr/src/external/lgpl3/mpc/dist/src --with-mpfr-include=/usr/src/external/lgpl3/mpfr/dist/src --with-gmp-include=/usr/src/external/lgpl3/gmp/lib/libgmp/arch/x86_64 --enable-tls --disable-multilib --disable-libstdcxx-pch --build=x86_64--netbsd --host=x86_64--netbsd --with-sysroot=/var/obj/mknative/amd64-x86_64/usr/src/destdir.amd64 Thread model: posix gcc version 9.3.0 (nb1 20200907) # gcc -fsanitize=leak test.c # ./a.out ================================================================= ==3113==ERROR: LeakSanitizer: detected memory leaks Direct leak of 1 byte(s) in 1 object(s) allocated from: #0 0x7f7ff70062d7 in __interceptor_malloc /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc:53 #1 0x400a74 in main ??:? #2 0x40095b in ___start ??:? SUMMARY: LeakSanitizer: 1 byte(s) leaked in 1 allocation(s). # ./a.out 1 2 3 ================================================================= ==16675==ERROR: LeakSanitizer: detected memory leaks Direct leak of 16 byte(s) in 4 object(s) allocated from: #0 0x7f7ff70062d7 in __interceptor_malloc /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc:53 #1 0x400a74 in main ??:? #2 0x40095b in ___start ??:? SUMMARY: LeakSanitizer: 16 byte(s) leaked in 4 allocation(s). # ./a.out 1 2 3 4 5 ================================================================= ==24914==ERROR: LeakSanitizer: detected memory leaks Direct leak of 36 byte(s) in 6 object(s) allocated from: #0 0x7f7ff70062d7 in __interceptor_malloc /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc:53 #1 0x400a74 in main ??:? #2 0x40095b in ___start ??:? SUMMARY: LeakSanitizer: 36 byte(s) leaked in 6 allocation(s). # gcc -fsanitize=leak test.c -g # ./a.out 1 2 3 4 5 ================================================================= ==4763==ERROR: LeakSanitizer: detected memory leaks Direct leak of 36 byte(s) in 6 object(s) allocated from: #0 0x7f7ff70062d7 in __interceptor_malloc /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc:53 #1 0x400a74 in main /tmp/test.c:9 (discriminator 3) #2 0x40095b in ___start ??:? SUMMARY: LeakSanitizer: 36 byte(s) leaked in 6 allocation(s). # ./a.out ================================================================= ==6199==ERROR: LeakSanitizer: detected memory leaks Direct leak of 1 byte(s) in 1 object(s) allocated from: #0 0x7f7ff70062d7 in __interceptor_malloc /usr/src/external/gpl3/gcc/dist/libsanitizer/lsan/lsan_interceptors.cc:53 #1 0x400a74 in main /tmp/test.c:9 (discriminator 3) #2 0x40095b in ___start ??:? SUMMARY: LeakSanitizer: 1 byte(s) leaked in 1 allocation(s). # cat test.c #include int main(int argc, char **argv) { int i; volatile void *ptr; for (i = 0; i < argc; i++) ptr = malloc(argc); return 0; }