Bug 7258

Summary: The message "variable might be used uninitialised" does not tell the location
Product: gcc Reporter: schnetter
Component: cAssignee: Not yet assigned to anyone <unassigned>
Severity: enhancement CC: bangerth, gcc-bugs, manu
Priority: P3 Keywords: diagnostic
Version: 2.95.3   
Target Milestone: 4.0.0   
Host: Target:
Build: Known to work:
Known to fail: 2.97 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1 3.1.1 3.1.2 3.2 3.2.1 3.2.2 3.2.3 3.3 3.3.1 3.3.2 3.3.3 3.4.0 4.0.0 Last reconfirmed: 2004-02-09 03:50:47
Bug Depends on:    
Bug Blocks: 24639    

Description schnetter 2002-07-10 02:36:01 UTC
The warning message "variable might be used uninitialised" gives as location the place where the variable is declared.  It would also be very useful if the compiler gave the location where the variable is used (without being initialised).  This location might be difficult to find if the variable is used several times in a longer function.

gcc 2.95.3

SuSE Linux 7.3
Comment 1 Wolfgang Bangerth 2002-12-03 14:59:45 UTC
State-Changed-From-To: open->analyzed
State-Changed-Why: Confirmed. Use the following, as an example:
    void g ();
    void f() {
      int i;
      if (i)
    The message is
    tmp/g> /home/bangerth/bin/gcc-3.3-pre/bin/gcc -W -Wall -Wuninitialized -O -c x.c
    x.c: In function `f':
    x.c:4: warning: `i' might be used uninitialized in this function
Comment 2 Wolfgang Bangerth 2002-12-03 17:02:06 UTC
From: Wolfgang Bangerth <bangerth@ticam.utexas.edu>
To: gcc-gnats@gcc.gnu.org, <gcc-bugs@gcc.gnu.org>
Subject: Re: c/7258: The message "variable might be used uninitialised" does
 not tell the location
Date: Tue, 3 Dec 2002 17:02:06 -0600 (CST)

 Regarding my confirmation message for this report:
 Too bad I deleted the line between functions g() and f() upon pasting, but 
 not updating the compiler output. With the given code, the warning is for
 line _3_, which is the declaration, not the use of 'i'.
 Wolfgang Bangerth              email:           bangerth@ticam.utexas.edu
                                www: http://www.ticam.utexas.edu/~bangerth
Comment 3 Andrew Pinski 2003-05-26 16:36:45 UTC
still happens on the mainline (20030526) and this would be nice:
pr7258.c: In function `f':
pr7258.c:3: warning: `i' might be used uninitialized in this function
Comment 4 Andrew Pinski 2004-04-27 03:32:41 UTC
Suspending as this is fixed on the tree-ssa:
pr7258.c: In function `f':
pr7258.c:4: warning: 'i' is used uninitialized in this function

Line 4 contains:
      if (i)

Also note for the "reduced" source it says "is" and not "might".
Comment 5 Andrew Pinski 2004-05-13 11:50:16 UTC
Fixed for 3.5.0 by the merge of the tree-ssa.
Comment 6 Manuel López-Ibáñez 2007-08-15 14:41:32 UTC
I am not so sure this is fixed. I need to double check this.