Skip to content

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

@smcclure15

Description

@smcclure15

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions