https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101408
Bug ID: 101408
Summary: [gcov] "__FLT_EVAL_METHOD__ " leads to incorrect
coverage of case statement
Product: gcc
Version: 11.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: gcov-profile
Assignee: unassigned at gcc dot gnu.org
Reporter: byone.heng at gmail dot com
CC: marxin at gcc dot gnu.org
Target Milestone: ---
$./gcc -v
Using built-in specs.
COLLECT_GCC=./gcc
COLLECT_LTO_WRAPPER=/home/x/project/gcc/build/install/libexec/gcc/x86_64-pc-linux-gnu/11.0.0/lto-wrapper
Target: x86_64-pc-linux-gnu
Configured with: ../configure --prefix=/home/x/project/gcc/build/install
--enable-checking=release --enable-languages=c,c++ --disable-multilib
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 11.0.0 20210105 (experimental) (GCC)
$cat test.c
static volatile unsigned long int true_var = 1;
static const unsigned char false_var = 0;
int main (int argc, char** argv)
{
switch (__FLT_EVAL_METHOD__)
{
case 0:
case 1:
case 2:
case -1:
return 0;
default:
return 1;
}
}
$gcc -O0 --coverage test.c;./a.out;gcov test;cat test.c.gcov
-: 4:static volatile unsigned long int true_var = 1;
-: 5:static const unsigned char false_var = 0;
-: 6:
-: 7:/* Test that we only see the C99/C11 values for
__FLT_EVAL_METHOD__ if
-: 8: we are compiling with -std=c11. */
-: 9:
1: 10:int main (int argc, char** argv)
-: 11:{
-: 12: switch (__FLT_EVAL_METHOD__)
-: 13: {
-: 14: case 0:
-: 15: case 1:
-: 16: case 2:
-: 17: case -1:
1: 18: return 0;
-: 19: default:
-: 20: return 1;
-: 21: }
-: 22:}
Line 14 should be executed one time.