Cppcheck produces no mismatchAllocDealloc diagnostic. The checker report lists CheckLeakAutoVar::check as active.
Expected behavior
Cppcheck should report mismatchAllocDealloc at line 7 because the pointer returned by allocate_array() was allocated with new[] but is deallocated with delete.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, I found a false negative in Cppcheck 2.22 dev when an array allocated with
new[]is returned by a function and deallocated withdelete.Affected tool
Cppcheck 2.22 dev (Git commit 71de6753d64f)Affected checker
Cppcheck mismatchAllocDeallocMinimal reproducer
Reproduction command
Current behavior
Cppcheck produces no
mismatchAllocDeallocdiagnostic. The checker report listsCheckLeakAutoVar::checkas active.Expected behavior
Cppcheck should report
mismatchAllocDeallocat line 7 because the pointer returned byallocate_array()was allocated withnew[]but is deallocated withdelete.See https://trac.cppcheck.net/ticket/3172