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: unassig...@gcc.gnu.org
        ReportedBy: paolo.carl...@oracle.com


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.

Reply via email to