This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/21750] New: GCC gives may be used uninitialized warning for a non-conditional initialised variable. (not a duplicate bug!)
- From: "j dot w dot r dot degoede at hhs dot nl" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 25 May 2005 12:56:12 -0000
- Subject: [Bug c/21750] New: GCC gives may be used uninitialized warning for a non-conditional initialised variable. (not a duplicate bug!)
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
I'm using Fedora Rawhide tree (FC4 develtree) the gcc rpm version is:
---
[hans@cq229 ~]$ rpm -q gcc
gcc-4.0.0-8
---
Gcc-version:
---
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-libgcj-multifile
--enable-languages=c,c++,objc,java,f95,ada --enable-java-awt=gtk
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --host=i386-redhat-linux
Thread model: posix
gcc version 4.0.0 20050519 (Red Hat 4.0.0-8)
---
Commandline triggering the bug:
---
gcc -o gglide.o -Wall -W -I. -I../../incsrc -I../../minihwc -I../../cinit
-I../../../swlibs/fxmisc -I../../../swlibs/newpci/pcilib
-I../../../swlibs/fxmemmap -I../../../swlibs/texus2/lib -D__linux__ -DDRI_BUILD
-DGLIDE3 -DGLIDE3_ALPHA -DGLIDE_HW_TRI_SETUP=1 -DGLIDE_INIT_HWC
-DGLIDE_PACKED_RGB=0 -DGLIDE_PACKET3_TRI_SETUP=1 -DGLIDE_TRI_CULLING=1
-DUSE_PACKET_FIFO=1 -DH3 -DFX_GLIDE_H5_CSIM=1 -DFX_GLIDE_NAPALM=1 -DGLIDE_PLUG
-DGLIDE_SPLASH -DHAVE_TEXUS2 -DGL_AMD3D -DGL_MMX -DGL_SSE -DGL_SSE2 -DGL_X86 -O2
-g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -m32 -march=i386 -mtune=pentium4
-fasynchronous-unwind-tables -Wno-unused-parameter -save-temps -c gglide.c
---
Compiling gglide.c with the above cmdline results in the following warnings:
---
gglide.c: In function ?_grBufferClear2D?:
gglide.c:957: warning: ?clip0min? may be used uninitialized in this function
gglide.c:964: warning: ?height? may be used uninitialized in this function
gglide.c:964: warning: ?width? may be used uninitialized in this function
gglide.c:957: warning: ?command? may be used uninitialized in this function
---
I've attached an .i file as instructed. line 957 => 7312 in the .i file.
Notice that command, width and height get initialised unconditional before use.
(the offsetoff use is use of a member of a struct with the same name not of the
variable).
I've seen this same bug in another file too. The strange thing is that moving
the "do { } while(0);" which contains "*_regGroupFifoPtr++ = ((height << 16) |
width);" up a bit to line 7404, which moves it over a block which doesn't touch
width or height makes the warning for width and height go away.
I've seen the same thing in the other file moving the code using the var up over
a (big) block which doesn't touch the var in any way makes the warning go away.
It is as if gcc forgets that the var has been initialised if it isn't used for a
number of lines.
--
Summary: GCC gives may be used uninitialized warning for a non-
conditional initialised variable. (not a duplicate bug!)
Product: gcc
Version: 4.0.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: j dot w dot r dot degoede at hhs dot nl
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21750