This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/50321] New: Erroneous unreachable code warning.
- From: "till at pps dot jussieu.fr" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 07 Sep 2011 14:22:44 +0000
- Subject: [Bug c/50321] New: Erroneous unreachable code warning.
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50321
Bug #: 50321
Summary: Erroneous unreachable code warning.
Classification: Unclassified
Product: gcc
Version: 4.4.4
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: till@pps.jussieu.fr
The following code:
extern int intf ( void );
extern void voidf ( void );
void f ( void ) {
int v = (intf ())?-1:0; /* Change -1 to 1 and the bug goes away*/
if (v) voidf ();
}
warns about unreachable code when compiled with
gcc -g -Werror -O1 -Wunreachable-code -c bug.c
(the -g is important)
cc1: warnings being treated as errors
bug.c: In function âfâ:
bug.c:5: error: will never be executed
The machine used to compile this is an up to date centos 6 x86_64 machine. The
full version of gcc is:
Using built-in specs.
Target: x86_64-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla
--enable-bootstrap --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-gnu-unique-object
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --disable-libjava-multilib
--with-ppl --with-cloog --with-tune=generic --with-arch_32=i686
--build=x86_64-redhat-linux
Thread model: posix
gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC)
The bug didn't appear on gcc 4.6 (debian) and 4.2. I suspect that this might be
caused by a red hat patch.