https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120491

--- Comment #1 from Wentao Zhang <wentaoz5 at illinois dot edu> ---
Here is a reduced program:

$ gcc --version | head -1
gcc (GCC) 16.0.0 20250511 (experimental)

$ cat > test.cc << 'EOF'
int g;

class C1 {
    int x;
    int y;
public:
    C1() {}
    C1(int x, int y) : x(x),
        y(y)
    { g++; }
};

class C2 : public C1 {
    int a;
    int b;
public:
    C2(int a, int b) : a(a),
        b(b)
    { g++; }
};

int main() {
    C1 c1(2, 3);
    C2 c2(11, 13);
}
EOF

$ g++ --coverage test.cc -o test; ./test; gcov test
$ grep -A2 ') : ' test.cc.gcov
        1:    8:    C1(int x, int y) : x(x),
        1:    9:        y(y)
        1:   10:    { g++; }
--
        2:   17:    C2(int a, int b) : a(a),
        1:   18:        b(b)
        1:   19:    { g++; }

The two constructors should have been invoked only once. But when (1) the 
class in question inherits from another (2) the initialization list is
written in multiple lines, i.e. "C2" at line 17, line coverage is wrongly
reported as "2".

Reply via email to