<html>
<head>
<base href="http://llvm.org/bugs/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW --- - gcov coverage data produced by clang is different from corresponding data produced by gcc"
href="http://llvm.org/bugs/show_bug.cgi?id=22084">22084</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>gcov coverage data produced by clang is different from corresponding data produced by gcc
</td>
</tr>
<tr>
<th>Product</th>
<td>new-bugs
</td>
</tr>
<tr>
<th>Version</th>
<td>unspecified
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>new bugs
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>simon.gardener@arcor.de
</td>
</tr>
<tr>
<th>CC</th>
<td>llvmbugs@cs.uiuc.edu
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr></table>
<p>
<div>
<pre>Created <span class=""><a href="attachment.cgi?id=13621" name="attach_13621" title="test.cpp, test.sh">attachment 13621</a> <a href="attachment.cgi?id=13621&action=edit" title="test.cpp, test.sh">[details]</a></span>
test.cpp, test.sh
Consider the C++ program 'test.cpp':
int foo()
{
return 0;
}
int main()
{
foo();
}
We are generating and comparing coverage data using g++ and clang++ together
with gcov:
g++ --coverage test.cpp:
-: 0:Source:test.cpp
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:1
-: 0:Programs:1
function _Z3foov called 1 returned 100% blocks executed 100%
1: 1:int foo()
-: 2:{
1: 3: return 0;
-: 4:}
-: 5:
function main called 1 returned 100% blocks executed 100%
1: 6:int main()
-: 7:{
1: 8: foo();
call 0 returned 100%
1: 9:}
clang++ --coverage -Xclang -coverage-cfg-checksum -Xclang
-coverage-no-function-names-in-data -Xclang -coverage-version='409*':
-: 0:Source:test.cpp
-: 0:Graph:test.gcno
-: 0:Data:test.gcda
-: 0:Runs:0
-: 0:Programs:1
function _Z3foov called 1 returned 100% blocks executed 100%
-: 1:int foo()
-: 2:{
1: 3: return 0;
-: 4:}
-: 5:
function main called 1 returned 100% blocks executed 100%
-: 6:int main()
-: 7:{
1: 8: foo();
1: 9:}
diff:
4c4
< -: 0:Runs:1
---
<span class="quote">> -: 0:Runs:0</span >
7c7
< 1: 1:int foo()
---
<span class="quote">> -: 1:int foo()</span >
13c13
< 1: 6:int main()
---
<span class="quote">> -: 6:int main()</span >
16d15
< call 0 returned 100%
Particularly, function heads are considered as covered lines of code when using
gcc but not when using clang.
Practical problem: lcov seems to rely on gcc-style. Generating initial zero
coverage data using 'lcov -c -i' considers function heads. This leads to wrong
results when combined with actual clang-style coverage data which does not
consider function heads.
Above data can be reproduced using the script 'test.sh' contained in the
attached archive.
Output of 'test.sh' on my machine:
g++ (GCC) 4.9.2 20141224 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
clang version 3.5.0 (tags/RELEASE_350/final)
Target: x86_64-unknown-linux-gnu
Thread model: posix
gcov (GCC) 4.9.2 20141224 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.
File 'test.cpp'
Lines executed:100.00% of 5
No branches
Calls executed:100.00% of 1
Creating 'test.cpp.gcov'
test.gcno:'_Z3foov' has arcs from exit block
test.gcno:'main' has arcs from exit block
File 'test.cpp'
Lines executed:100.00% of 3
No branches
No calls
Creating 'test.cpp.gcov'
4c4
< -: 0:Runs:1
---
<span class="quote">> -: 0:Runs:0</span >
7c7
< 1: 1:int foo()
---
<span class="quote">> -: 1:int foo()</span >
13c13
< 1: 6:int main()
---
<span class="quote">> -: 6:int main()</span >
16d15
< call 0 returned 100%</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>