[Bug tree-optimization/26724] New: __builtin_constant_p fails to recognise function with constant return
anton at samba dot org
gcc-bugzilla@gcc.gnu.org
Fri Mar 17 07:06:00 GMT 2006
We noticed that __builtin_constant_p() sometimes fails to recognise a function
that always returns 0 as being constant.
The code snippet below shows that gcc can work it out if we force the
evaluation into an inline function. It looks like this postpones the evaluation
of __builtin_constant_p to a later stage when we know the function always
returns 0.
static inline int baz(void)
{
return 0;
}
void inline foo(int A)
{
if (!__builtin_constant_p(A))
FAIL();
}
void good()
{
foo(baz());
}
void bad()
{
if (!__builtin_constant_p(baz()))
FAIL();
}
--
Summary: __builtin_constant_p fails to recognise function with
constant return
Product: gcc
Version: 4.2.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: anton at samba dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26724
More information about the Gcc-bugs
mailing list