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

--- 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.c << 'EOF'
int g;

static inline __attribute__((always_inline))
int foo() { return 0; }

#define PROCESS g = foo()

int main(void) {
    int x = 1;
    switch(x) {
    case 1:       g++;
                  PROCESS;
    case 2:       PROCESS;
    case 3:       PROCESS;
                  g++;
    case 4:       g++;
    }
}
EOF

$ gcc --coverage test.c -o test; ./test; gcov test
$ grep -A7 switch test.c.gcov
        1:   10:    switch(x) {
        1:   11:    case 1:       g++;
        1:   12:                  PROCESS;
        2:   13:    case 2:       PROCESS;
        1:   14:    case 3:       PROCESS;
        1:   15:                  g++;
        1:   16:    case 4:       g++;
        -:   17:    }

The whole "switch" statement should have been executed once, every "case"
label falls through to its next. But when the macro is the only thing for
that "case", line coverage is wrongly reported to be "2".

Reply via email to