This problem is present in at least gcc-3.4.[123], gcc-3.4-20050401, and gcc-4.0-20050305. I have not tested a later gcc-4.0 yet.
Create a test file pgo.cc: #include <iostream> namespace { void func() { std::cout << "In func" << std::endl; } } int main() { func(); } Compile it, run it, and recompile it as follows: i686-unknown-linux-gnu-g++ -fprofile-generate -o pgo pgo.cc ./pgo i686-unknown-linux-gnu-g++ -fprofile-use -o pgo pgo.cc The -fprofile-use compilation fails with pgo.cc: In function 'void<unnamed>::func()': pgo.cc:6: error: coverage mismatch for function '_ZN35_GLOBAL__N_pgo.cc_00000000_8B40D3D54funcEv' while reading counter 'arcs'. pgo.cc:6: error: checksum is 5c057dbb instead of 3746c244 Commenting out the namespace makes the problem go away. This keeps me from building some real apps with profile-driven optimization, which may result in switching from gcc to icc for this app. Thanks to Simon Baldwin for finding such a nice little test case for this. -- Summary: -fprofile-use barfs with "coverage mismatch for function '...' while reading counter 'arcs'." Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: rtl-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: dank at kegel dot com CC: gcc-bugs at gcc dot gnu dot org GCC target triplet: i686-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20815