LINUX.ORG.RU

История изменений

Исправление LebedevRI, (текущая версия) :

$ clang++ -std=c++11 -fsanitize=memory -fsanitize-memory-use-after-dtor -g test.cpp 
$ MSAN_OPTIONS=poison_in_dtor=1 ./a.out 
Calling A destructor
Calling B destructor
Attempt to delete A, refCount is 3
==7372==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x2c95bd in A::operator delete(void*) /tmp/test.cpp:26:13
    #1 0x2c9a45 in A::~A() /tmp/test.cpp:16:18
    #2 0x2c9106 in main /tmp/test.cpp:44:9
    #3 0x7f200bcb0f29 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20f29)
    #4 0x24d029 in _start (/tmp/a.out+0x24d029)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/test.cpp:26:13 in A::operator delete(void*)
Exiting

> -fsanitize
В тех случаях, когда возможно запустить valgrind, лучше запускать valgrind.

Аргументы будут?

Исходная версия LebedevRI, :

$ clang++ -std=c++11 -fsanitize=memory -fsanitize-memory-use-after-dtor -g test.cpp 
$ MSAN_OPTIONS=poison_in_dtor=1 ./a.out 
Calling A destructor
Calling B destructor
Attempt to delete A, refCount is 3
==7372==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x2c95bd in A::operator delete(void*) /tmp/test.cpp:26:13
    #1 0x2c9a45 in A::~A() /tmp/test.cpp:16:18
    #2 0x2c9106 in main /tmp/test.cpp:44:9
    #3 0x7f200bcb0f29 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x20f29)
    #4 0x24d029 in _start (/tmp/a.out+0x24d029)

SUMMARY: MemorySanitizer: use-of-uninitialized-value /tmp/test.cpp:26:13 in A::operator delete(void*)
Exiting