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 7258 - The message "variable might be used uninitialised" does not tell the location
Summary: The message "variable might be used uninitialised" does not tell the location
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c (show other bugs)
Version: 2.95.3
: P3 enhancement
Target Milestone: 4.0.0
Assignee: Not yet assigned to anyone
URL:
Keywords: diagnostic
Depends on:
Blocks: Wuninitialized
  Show dependency treegraph
 
Reported: 2002-07-10 02:36 UTC by schnetter
Modified: 2007-08-15 14:41 UTC (History)
3 users (show)

See Also:
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


Attachments

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

Release:
gcc 2.95.3

Environment:
SuSE Linux 7.3
i386
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)
        g();
    };
    ----------------------
    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>
Cc:  
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'.
 
 W.
 
 -------------------------------------------------------------------------
 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.