http://gcc.gnu.org/bugzilla/show_bug.cgi?id=46476
Summary: Missing Warning about unreachable code after return
Product: gcc
Version: 4.6.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c++
AssignedTo: [email protected]
ReportedBy: [email protected]
It seems impossible to me that this issue has not been discussed already, but
in the library I fixed only two weeks ago a *very* stupid bug which went
unnoticed for *many* months exactly because of this. Couldn't believe that GCC
didn't warn even at -Wall -Wextra (and -O2). Thus:
int foo(int& num)
{
return num;
++num; // Warn!
}
int bar(int num)
{
return num;
++num; // Warn!
return num;
}
For the record, ICC *does* warn, with -Wall.