http://gcc.gnu.org/bugzilla/show_bug.cgi?id=53896
Bug #: 53896
Summary: nonreturning function suggested as 'pure' candidate
Classification: Unclassified
Product: gcc
Version: 4.7.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: [email protected]
ReportedBy: [email protected]
I ran into this problem when building a test version of Emacs
with GCC 4.7.1 (x86-64). I simplified it to a small test case.
Take this program:
void lose (const char *msg) __attribute__((__noreturn__));
const char *
get_prefix (int running_suid)
{
if (!running_suid)
lose ("Not using a shared game directory, and no prefix given.");
return "foo";
}
Compile it with:
gcc -c -O2 -Wsuggest-attribute=pure t.c
The output will be:
t.c:4:1: warning: function might be candidate for attribute 'pure' if it is
known to return normally [-Wsuggest-attribute=pure]
But the get_prefix function is obviously not a candidate for attribute
'pure', since it might not return.
This bug may be related to Bug#50021 (currently apparently fixed in
GCC 4.7.0) and to Bug#51971 (documentation unclear for 'pure').