This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/17544] New: incorrect -Wunreachable-code warning for reachable code following a do statement
- From: "sebor at roguewave dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 18 Sep 2004 00:17:22 -0000
- Subject: [Bug c++/17544] New: incorrect -Wunreachable-code warning for reachable code following a do statement
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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