Description of Problem: g++ seems to erroneously report a statement as "unreachable" ... Version-Release number of selected component (if applicable): [bill@pikachu bill]$ rpm -q gcc-c++ gcc-c++-3.1-0.21 How Reproducible: Well, I'll attach the code in a moment ... [bill@pikachu tmp]$ c++ -O2 -W -Wall -Weffc++ -Wunreachable-code -g -c -o bug4.o bug4.c++ bug4.c++: In function `void three(fum*, const char*)': bug4.c++:63: warning: will never be executed bug4.c++:58: warning: will never be executed The code at line 58 is a return statement which certainly should be executed. The odd part is line 63: it should be reachable if the condition at line 45 is not met during the loop. Unless I'm losing my marbles again. But since gcc doesn't know what value is going to be passed in, it can't know whether the condition will be true.
Created attachment 45157 [details] Offending example of source, distilled from a real-life example
Created attachment 45158 [details] Oddly, NO warning is issued for this case (where the last line IS unreachable due to the two return statements)
Fixed in CVS, will appear in gcc-3.1-0.22.
I'm still seeing a warning for the first example, which I'm pretty sure is wrong. [bill@pikachu tmp]$ c++ -W -Wall -Wunreachable-code -O2 -c bug4.c++ bug4.c++: In function `void three(fum*, const char*)': bug4.c++:57: warning: will never be executed bug4.c++:47: warning: will never be executed I am however now getting a valid warning for the second example, as I should: [bill@pikachu tmp]$ c++ -W -Wall -Wunreachable-code -O2 -c bug5.c++ bug5.c++: In function `void three(fum*, const char*)': bug5.c++:56: warning: will never be executed If it'll help I can probably supply some more examples ... I get loads of warnings from some code I'm messing with at the moment. It's horrid code, but works ...
Definitely not present in gcc 3.2.