This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/17544] New: incorrect -Wunreachable-code warning for reachable code following a do statement


The warning below is incorrect -- the program always reaches the flagged line.
Note that replacing the do statement with a for or while statement eliminates
the warning.

$ cat -n u.cpp && g++ -O -Wunreachable-code u.cpp && ./a.out a; echo $?
     1  int main (int argc, char *argv[])
     2  {
     3      const char* const s = argc < 2 ? "" : argv [1];
     4
     5      int i = 0;
     6
     7      do {
     8          ++i;
     9      } while (i < s [0]);
    10
    11      return i;
    12  }
    13
u.cpp: In function `int main(int, char**)':
u.cpp:11: warning: will never be executed
97

-- 
           Summary: incorrect -Wunreachable-code warning for reachable code
                    following a do statement
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: sebor at roguewave dot com
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: all
  GCC host triplet: all
GCC target triplet: all


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=17544


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]