I\'m using gcov for the first time and I\'m having a problem which is similar to the one reported in this thread. However, I wasn\'t able to solve my problem following the comme
I want to complete the answer that I gave to @Klaus.
Both combinations "-O2 -g" and "-O2" gives the following coverage information for this method (I inserted the message only to be sure that the method was being executed in the tests):
-: 192: const QString& institutionId(void) const {
1: 193: std::cout << "Inside institutionId\n";
-: 194: return m_institution;
-: 195: }
That means that the lines 192 and 194 are not considered as executable, but only the cout. The flag -g does not affect the result (at least in this case).
If I build the program using "-O0", the result is:
1: 192: const QString& institutionId(void) const {
1: 193: std::cout << "Inside institutionId\n";
1: 194: return m_institution;
-: 195: }