cpp-coveralls icon indicating copy to clipboard operation
cpp-coveralls copied to clipboard

Templated methods shift line numbers and produce unreliable coverage for the tail of the file

Open smcclure15 opened this issue 1 year ago • 0 comments

My .gcno files get transformed into .gcov files that end up looking like the following:

        -:   99:
        -:  100:template <typename T>
    #####:  101:void times2(T x) {
    #####:  102:    return 2*x;
        -:  103:}
------------------
debugsymbolA:
        -:  100:template <typename T>
    #####:  101:void times2(T x) {
    #####:  102:    return 2*x;
        -:  103:}
------------------
debugsymbolB:
        -:  100:template <typename T>
    #####:  101:void times2(T x) {
    #####:  102:    return 2*x;
        -:  103:}
------------------
        -:  104:

The times2 function is templated and listed several times with the different debug symbol identifiers.

cpp-coveralls simply appends a new element to its coverage array for each line, so the lines 100-103 are counted 3 times each, which causes a shift in the reported lines (and they end up going "off the end" of the file contents because it is now larger than the number of lines in the file). This makes all the coverage lines after this inconsistent and unreliable (and also undetectable to the typical user reading the report).

smcclure15 avatar Jul 31 '24 15:07 smcclure15