Bug 24968 - wrong "will never be executed" warning
Summary: wrong "will never be executed" warning
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 3.4.4
: P3 normal
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-11-21 12:09 UTC by Oliver Stoeneberg
Modified: 2005-11-21 13:17 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Oliver Stoeneberg 2005-11-21 12:09:51 UTC
The following source will report

C:\Dev-Cpp\Projects\test-stlport\main_17.cpp In function `void test_17()': 
12 C:\Dev-Cpp\Projects\test-stlport\main_17.cpp [Warning] will never be executed
12 C:\Dev-Cpp\Projects\test-stlport\main_17.cpp [Warning] will never be executed

when using "-Wunreachable-code"

I reduced this from a way bigger source file with STL and even more if - else involved and this was the only two warnings from the beginning (whole file) to the end (this sample). Happens with C and C++.

void test_17()
{
 	int pos = 1; 
 	while(1) {
		if ( pos )
		{
			if ( pos == 2 ) /* */
			{
			}
			else
			{
				break;
			}
		}
		else
		{
			break;
		}
	}
}

C:\MinGW_3.4.4\bin>gcc -v
Reading specs from ../lib/gcc/mingw32/3.4.4/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable
-languages=c,c++,f77,ada,objc,java --disable-win32-registry --disable-shared --e
nable-sjlj-exceptions --enable-libgcj --disable-java-awt --without-x --enable-ja
va-gc=boehm --disable-libgcj-debug --enable-interpreter --enable-hash-synchroniz
ation --enable-libstdcxx-debug
Thread model: win32
gcc version 3.4.4 (mingw special)
Comment 1 Andrew Pinski 2005-11-21 13:17:25 UTC
Fixed for 4.0.0.