[Bug c++/46476] New: Missing Warning about unreachable code after return

paolo.carlini at oracle dot com gcc-bugzilla@gcc.gnu.org
Sun Nov 14 17:13:00 GMT 2010


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: unassigned@gcc.gnu.org
        ReportedBy: paolo.carlini@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.



More information about the Gcc-bugs mailing list