GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.

Bug 21750

Summary: GCC gives may be used uninitialized warning for a non-conditional initialised variable. (not a duplicate bug!)
Product: gcc Reporter: Hans de Goede <j.w.r.degoede>
Component: middle-endAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED DUPLICATE    
Severity: normal CC: dnovillo, gcc-bugs, j.w.r.degoede, James.Juran, rth, thutt, william
Priority: P2 Keywords: diagnostic
Version: 4.0.0   
Target Milestone: ---   
Host: Target:
Build: Known to work:
Known to fail: Last reconfirmed: 2005-11-26 07:40:34
Bug Depends on:    
Bug Blocks: 24639    
Attachments: File causing problem

Description Hans de Goede 2005-05-25 12:56:01 UTC
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.
Comment 1 Hans de Goede 2005-05-25 12:57:07 UTC
Created attachment 8965 [details]
File causing problem
Comment 2 Andrew Pinski 2005-11-26 16:39:26 UTC
We have:
 if (gc->contextP) { 
...
set hieght
set width
set clip0min
set command
...
}
...
if (xxxxxx) {....}
...
if (gc->contextP) {
...
use clipOmin
use command
use hieght
use width
use clip0min
...
}

Anyways this is a dup of bug 5035

*** This bug has been marked as a duplicate of 5035 ***