Compiling the following code with
/home/veksler/gcc-4.0.0/bin/g++ -Wall -O2 -c bug.cpp
(Works fine with -O0 or with gcc-3.4.3)
Gives:
bug.cpp: In function 'bool foo(bar*, bar*)':
bug.cpp:19: warning: control may reach end of non-void function 'bool
bar_less::operator()(bar*, bar*)' being inlined
Which:
1. Is obviously incorrect.
2. Does not give a line number inside bar_less::operator()
---------- bug.cpp ---
struct bar;
bool operator<(const bar&, const bar&);
class bar_less
{
public:
bool operator()(bar* x, bar* y)
{
bool validX = x, validY = y;
if(validX && validY)
return (*x < *y);
else
return false;
}
};
bool foo(bar *x, bar *y)
{
bar_less comp;
return comp(x,y);
}
--
Summary: Spurious 'control may reach end of non-void function'
... being inlined
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: veksler at il dot ibm dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21483