I'm using unittest-cpp library. And I decided to check for memory leaks one of the units with valgrind help. I got such report:
==35820== HEAP SUMMARY:
==35820== in use at exit: 26,151 bytes in 188 blocks
==35820== total heap usage: 259 allocs, 71 frees, 32,151 bytes allocated
==35820==
==35820== 148 (80 direct, 68 indirect) bytes in 1 blocks are definitely lost in loss record 43 of 65
==35820== at 0x100023D81: malloc (vg_replace_malloc.c:303)
==35820== by 0x1002CB8D6: __Balloc_D2A (in /usr/lib/system/libsystem_c.dylib)
==35820== by 0x1002CC21F: __d2b_D2A (in /usr/lib/system/libsystem_c.dylib)
==35820== by 0x1002C8877: __dtoa (in /usr/lib/system/libsystem_c.dylib)
==35820== by 0x1002F13E6: __vfprintf (in /usr/lib/system/libsystem_c.dylib)
==35820== by 0x10031A6C8: __v2printf (in /usr/lib/system/libsystem_c.dylib)
==35820== by 0x1002F0389: vfprintf_l (in /usr/lib/system/libsystem_c.dylib)
==35820== by 0x1002EE223: printf (in /usr/lib/system/libsystem_c.dylib)
==35820== by 0x10000AA59: UnitTest::TestReporterStdout::ReportSummary(int, int, int, float) (TestReporterStdout.cpp:43)
==35820== by 0x10000AF9E: UnitTest::TestRunner::Finish() const (TestRunner.cpp:43)
==35820== by 0x10000B2F4: int UnitTest::TestRunner::RunTestsIf(UnitTest::TestList const&, char const*, UnitTest::True const&, int) const (in ./BuilderTests)
==35820== by 0x10000ACEF: UnitTest::RunAllTests() (TestRunner.cpp:17) ==35820==
==35820== LEAK SUMMARY:
==35820== definitely lost: 80 bytes in 1 blocks
==35820== indirectly lost: 68 bytes in 2 blocks
==35820== possibly lost: 2,064 bytes in 1 blocks
==35820== still reachable: 4,096 bytes in 1 blocks
==35820== suppressed: 19,843 bytes in 183 blocks
But valgrind didn't point to my code. Then I decided to build and check units from the GSL library, which uses unittest-cpp too. And I got the same report.
Can I trust valgrind?