Bug 21750 - GCC gives may be used uninitialized warning for a non-conditional initialised variable. (not a duplicate bug!)
Summary: GCC gives may be used uninitialized warning for a non-conditional initialised...
Status: RESOLVED DUPLICATE of bug 5035
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.0.0
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2005-05-25 12:56 UTC by Hans de Goede
Modified: 2005-11-26 16:39 UTC (History)
7 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-26 07:40:34


Attachments
File causing problem (42.72 KB, text/plain)
2005-05-25 12:57 UTC, Hans de Goede
Details

Note You need to log in before you can comment on or make changes to this bug.
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 ***