https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92666
Bug ID: 92666 Summary: bogus -Wunused-but-set-variable in gcov.c with -Wno-restrict Product: gcc Version: 10.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gcc dot gnu.org Target Milestone: --- Bootstrap with -Wno-restrict fails due to -Werror=unused-but-set-variable in gcc/gcov.c: /src/gcc/svn/gcc/gcov.c: In function ‘const char* format_count(gcov_type)’: /src//gcc/svn/gcc/gcov.c:2328:9: warning: variable ‘r’ set but not used [-Wunused-but-set-variable] 2328 | float r = 1.0f * count / divisor; | ^ A small test case reduced from the file is as follows. This is not reproducible with the C front-end: $ cat t.c && gcc -O2 -S -Wall -Wextra -Wno-restrict -xc++ t.c extern "C" int printf (const char*, ...); void f (unsigned n) { int i = 0; while (n >>= 1) ++i; float r = 1.0f * i; printf ("%f", r); } t.c: In function ‘void f(unsigned int)’: t.c:8:9: warning: variable ‘r’ set but not used [-Wunused-but-set-variable] 8 | float r = 1.0f * i; | ^