http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60716
Bug ID: 60716
Summary: gcc cannot detect static recursive function
Product: gcc
Version: 4.9.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
Assignee: unassigned at gcc dot gnu.org
Reporter: dcb314 at hotmail dot com
I just tried to bootstrap gcc trunk with the clang compiler.
It said
../../src/trunk/gcc/emit-rtl.c:2464:1: warning: function 'verify_rtx_sharing'
is not needed and will not be emitted [-Wunneeded-internal-declaration]
It seems that function verify_rtx_sharing is recursive and static, but no
other function calls it.
gcc doesn't seem able to detect this unusual code.
Example code would be
static int f( int n)
{
if (n == 1)
return 1;
else
return n * f( n - 1);
}
[dcb@zippy4 Alphasrc]$ gcc -g -O2 -Wall -c mar31a.cc
[dcb@zippy4 Alphasrc]$ clang++ -g -O2 -Wall -c mar31a.cc
mar31a.cc:2:12: warning: function 'f' is not needed and will not be emitted
[-Wunneeded-internal-declaration]
static int f( int n)
^
1 warning generated.
This bug may be related to #36392.