I can also reproduce this with clang 15.0.7 (Fedora 15.0.7-2.fc37) on CppCheck 5a7c7b9b5a17a8fcd212e7b77f6b5777b6c34479 (current git main). AddressSanitizer says it's a use-after-free: $ cppcheck/build/bin/cppcheck --clang=/usr/bin/clang++-15 --cppcheck-build-dir=cppcheck_build_dir test1.cpp Checking test1.cpp... ================================================================= ==1021405==ERROR: AddressSanitizer: heap-use-after-free on address 0x60c000006dc0 at pc 0x000000da8b5b bp 0x7ffdf6182690...