I am using SonarQube Server to display code coverage reports on a C++ project (using gcov to generate reports). For some files in my project, there are lines in SonarQube that display as "not covered by tests" when the gcov report shows otherwise (lines executed 100%).
Example gcov report (This has been condensed from my actual report):
-: 0:Source:/data/home/user/repos/test_projects/include/test.h
-: 1:namespace test {
-: 2:
-: 3:template <class DataT>
10: 4:std::unique_ptr<Test<DataT>>> create(std::istream&& input) {
-: 5:
10: 6: if (!input.good()) {
1*: 7: return false;
-: 8: }
-: 9:
.
. # Intermediate steps
.
-: 54:
9: 55: if (!result) {
1*: 56: return false;
-: 57: }
.
. # Intermediate steps
.
10*: 62:}
------------------
.
.
.
Using the above report, SonarQube Server shows "Fully covered by tests" on line 7, but "Not covered by tests "on line 56 when they both reported the same (1*). That is, they have the same total number of executions and have an unexpected basic block (still not entirely sure what that term means, but that is why the asterisk is there according to gcov).
I have a designated (googletest) unit test for each of the two conditions and they both pass. Furthermore, I am only using a single unit test executable to generate the coverage so there should not be colliding reports for different execution paths. I know SonarQube does not generate the coverage reports, and simply just interprets them. This led me to believe that this is an issue with my gcov configuration, but I am really just lost as to how SonarQube is interpreting the coverage of these 2 lines differently?
Other info: gcov (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)