https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080
Bug ID: 68080 Summary: gcov returns negative counts Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: gcov-profile Assignee: unassigned at gcc dot gnu.org Reporter: Pidgeot18 at gmail dot com Target Milestone: --- Created attachment 36576 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36576&action=edit File to run (See also bug 67937 for bad things that happen when this occurs). I finally minimized a test case that causes negative counts to happen. If you name the attached file TestDeadlockDetector.cpp and run: rm -rf *.gcda && c++ --coverage -std=c++11 -pthread -Os TestDeadlockDetector.cpp && ./a.out && gcov -a -b -p TestDeadlockDetector.gcda && grep -- '-[0-9][0-9]*:' TestDeadlockDetector.cpp.gcov you should usually see ContentionNoDeadlock_thread have negative counts. The exact count changes from each run (and sometimes, it's not negative). The -Os is in the c++ command line is definitely required.