https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115047
Bug ID: 115047
Summary: Inconsistent MC/DC reported by GCC and LLVM
Product: gcc
Version: 14.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: wentaoz5 at illinois dot edu
Target Milestone: ---
How to reproduce:
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/gcc-latest/libexec/gcc/x86_64-pc-linux-gnu/14.0.1/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/opt/gcc-latest --enable-languages=c,c++
--enable-libstdcxx-debug --enable-libstdcxx-backtrace --disable-bootstrap
--disable-multilib --disable-libvtv --with-system-zlib --without-isl
--enable-multiarch
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 14.0.1 20240421 (experimental) (GCC)
$ clang -v
Ubuntu clang version 18.1.3
(++20240322073153+ef6d1ec07c69-1~exp1~20240322193300.86)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/lib/llvm-18/bin
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/11
Candidate multilib: .;@m64
Selected multilib: .;@m64
$ cat > test.c << EOF
void f(int a, int b, int c) { a && b || c; }
int main(void) {
f(0,0,1);
f(1,0,0);
return 0;
}
EOF
$ gcc --coverage -fcondition-coverage test.c -o test
$ ./test
$ gcov --conditions test.c
$ cat test.c.gcov
File 'test.c'
Lines executed:100.00% of 5
Condition outcomes covered:50.00% of 6
Creating 'test.c.gcov'
Lines executed:100.00% of 5
-: 0:Source:test.c
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
2: 1:void f(int a, int b, int c) { a && b || c; }
condition outcomes covered 3/6
condition 0 not covered (true false)
condition 1 not covered (true)
1: 2:int main(void) {
1: 3: f(0,0,1);
1: 4: f(1,0,0);
1: 5: return 0;
-: 6:}
$ clang -Wno-unused-value -fprofile-instr-generate -fcoverage-mapping
-fcoverage-mcdc test.c -o test
$ ./test
$ llvm-profdata merge default.profraw -o default.profdata
$ llvm-cov show --show-mcdc -instr-profile default.profdata test
1| 2|void f(int a, int b, int c) { a && b || c; }
------------------
|---> MC/DC Decision Region (1:31) to (1:42)
|
| Number of Conditions: 3
| Condition C1 --> (1:31)
| Condition C2 --> (1:36)
| Condition C3 --> (1:41)
|
| Executed MC/DC Test Vectors:
|
| C1, C2, C3 Result
| 1 { T, F, F = F }
| 2 { F, -, T = T }
|
| C1-Pair: not covered
| C2-Pair: not covered
| C3-Pair: not covered
| MC/DC Coverage for Decision: 0.00%
|
------------------
2| 1|int main(void) {
3| 1| f(0,0,1);
4| 1| f(1,0,0);
5| 1| return 0;
6| 1|}
In this example, gcov believes condition "c" is covered but LLVM reports that
none of the conditions is covered.