First Last Prev Next    No search results available      Search page      Enter new bug
Bug#: 179
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Not yet assigned to anyone <unassigned@gcc.gnu.org>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: martin@v.loewis.de
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 179 depends on: Show dependency tree
Show dependency graph
Bug 179 blocks: 19430 24639

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2007-08-16 10:19 Opened: 2000-04-22 00:16
 Original-Message-Id: <m12ilS7-000QqwC@whopper.256.com>
 Date: Fri, 21 Apr 2000 17:59:07 -0400 (EDT)

 System and gcc version:

     Linux squirrel 2.2.14 #6 Mon Jan 31 14:32:43 EST 2000 i686 unknown
     gcc version 2.95.2 19991024 (release)

 The following program will not generate an error:

     #include <stdio.h>
     void foo(int *i_p) {}
     int main()
     {
       int i;
       if (i) (void)printf("%d?\n", i);
       /* ^^^ use of unitialized variable */
       foo(&i);
       /*  ^^ the reason why it isn't reported */
       return 0;
     }

 If you remove the foo(&i) or substitute a i = 1 then it will see that
 the if (i) line accesses a unitialized variable.

 I'd call it a bug although it might be a by-product of block processing
 in function.c.

 Comments?
 ---
 gray.reply@256.com


------------------------------------------------------------
[ Reported to the Debian BTS as report #117765.
  Please CC 117765@bugs.debian.org on replies.
  Log of report can be found at http://bugs.debian.org/117765 ]
 <precise description of the problem (multiple lines)>

[ rechecked with gcc-3_3-branch 20021227 ]

(Wall includes Wunitialized, but I included both as "belt and braces".)

chiark:~/gcc-problem:12$ gcc -c -g -O3 -Wall -Wuninitialized warning-test.c -o warning-test -DMHP_TEST_WARNING
chiark:~/gcc-problem:13$

Doesn't give any warning about the timeout not being initialised. (I've
tried with varying -O options, and with and without -c, none help.)

If I remove the never used sscanf it does.  (Note ptr is set to NULL and
never changed.)

chiark:~/gcc-problem:11$ gcc -c -g -O3 -Wall -Wuninitialized warning-test.c -o warning-test
warning-test.c: In function `main':
warning-test.c:8: warning: unused variable `ptr'
warning-test.c:6: warning: `timeout' might be used uninitialized in this function

This may be related to a bug reported in gcc 2.95 on the gcc Gnatsweb
(PR 179) at http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view&pr=179.  As I
am unsure I thought I'd report it anyway.

warning-test.c follows:
#include <stdio.h>
#include <stdlib.h>

int main (int argc, char ** argv)
{
  int timeout, timeout_offset;
  int rv;
  char * ptr = NULL;

  timeout_offset = 100;

#ifdef MHP_TEST_WARNING 
  if (ptr) {
    sscanf(ptr+timeout_offset, "%d", &timeout);
    printf("Found timeout\n");
  }
#endif

  rv = timeout;

  return rv;
}

Release:
2.95.x 3.x

------- Comment #1 From Joseph S. Myers 2001-01-14 11:58 -------
From: "Joseph S. Myers" <jsm28@cam.ac.uk>
To: gcc-gnats@gcc.gnu.org
Cc:  
Subject: c/179
Date: Sun, 14 Jan 2001 11:58:58 +0000 (GMT)

 I've entered a testcase for this bug as gcc.dg/uninit-B.c (XFAIL, as with
 many of the -Wuninitialized testcases).
 
 -- 
 Joseph S. Myers
 jsm28@cam.ac.uk
 


------- Comment #2 From Nathanael C. Nerode 2002-10-30 16:57 -------
From: Nathanael Nerode <neroden@twcny.rr.com>
To: martin@loewis.home.cs.tu-berlin.de, gcc-gnats@gcc.gnu.org,
   gcc-prs@gcc.gnu.org, jsm28@cam.ac.uk, gcc-bugs@gcc.gnu.org,
   nobody@gcc.gnu.org, gray.reply@256.com
Cc:  
Subject: Re: middle-end/179: gcc -O2 -Wuninitialized bug with &var under 2.95.2
Date: Wed, 30 Oct 2002 16:57:03 -0500

 Is this bug still valid against 3.x series gcc?
 
 http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=179
 


------- Comment #3 From Nathanael C. Nerode 2003-03-12 16:03 -------
From: Nathanael Nerode <neroden@twcny.rr.com>
To: gcc-gnats@gcc.gnu.org, martin@v.loewis.de, gray.reply@256.com,
   gcc-bugs@gcc.gnu.org, 117765@bugs.debian.org, jsm28@cam.ac.uk,
   nobody@gcc.gnu.org, gcc-prs@gcc.gnu.org
Cc:  
Subject: Re: middle-end/179: gcc -O2 -Wuninitialized bug ...
Date: Wed, 12 Mar 2003 16:03:44 -0500

 Confirmed still present in mainline (thanks to the XFAILed testcase).

------- Comment #4 From Andrew Pinski 2003-11-16 00:09 -------
Suspending as it is fixed on the tree-ssa branch.

------- Comment #5 From Andrew Pinski 2003-12-17 00:40 -------
Leaving as suspending as someone needs to update the testcase.

------- Comment #6 From Andrew Pinski 2004-05-13 11:31 -------
Fixed for 3.5.0 by the merge of the tree-ssa.

------- Comment #7 From Andrew Pinski 2004-08-25 21:16 -------
*** Bug 17191 has been marked as a duplicate of this bug. ***

------- Comment #8 From Andrew Pinski 2004-08-25 21:16 -------
*** Bug 17172 has been marked as a duplicate of this bug. ***

------- Comment #9 From Manuel López-Ibáñez 2007-08-15 14:22 -------
(In reply to comment #8)
> *** Bug 17172 has been marked as a duplicate of this bug. ***
> 
I see that the xfail is still there, so how can this be fixed ?
http://gcc.gnu.org/svn/gcc/trunk/gcc/testsuite/gcc.dg/uninit-B.c

------- Comment #10 From Manuel López-Ibáñez 2007-08-16 10:19 -------
Some analysis http://gcc.gnu.org/ml/gcc/2007-08/msg00271.html

------- Comment #11 From Richard Guenther 2008-01-13 15:40 -------
Non-regressions should not have a target milestone set.

------- Comment #12 From Manuel López-Ibáñez 2008-08-11 13:18 -------
Patch: 

http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00696.html

Comments welcome!

------- Comment #13 From Manuel López-Ibáñez 2008-08-20 22:25 -------
Subject: Bug 179

Author: manu
Date: Wed Aug 20 22:23:45 2008
New Revision: 139347

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=139347
Log:
2008-08-21  Manuel Lopez-Ibanez  <manu@gcc.gnu.org>

        PR middle-end/179
        * tree-ssa.c (warn_uninit): Do not warn for variables that can be
        initialized outside the current module.
        (warn_uninitialized_var): Ignore left-hand side when walking the
        trees. Ignore address expressions. Examine VUSE operands in gimple
        statements with a variable declaration on the right-hand side.
testsuite/
        * gcc.dg/uninit-6.c (make_something): Remove XFAIL.
        * gcc.dg/uninit-6-O0.c (make_something): Remove XFAIL.
        * gcc.dg/uninit-B.c (baz): Remove XFAIL.
        * gcc.dg/uninit-B-2.c: New.
        * gcc.dg/uninit-B-O0-2.c: New.
        * gcc.dg/uninit-pr19430-O0.c: New.
        * gcc.dg/uninit-pr19430.c: New.
        * gcc.dg/uninit-pr19430-2.c: New.

Added:
    trunk/gcc/testsuite/gcc.dg/uninit-B-2.c
    trunk/gcc/testsuite/gcc.dg/uninit-B-O0-2.c
    trunk/gcc/testsuite/gcc.dg/uninit-pr19430-2.c
    trunk/gcc/testsuite/gcc.dg/uninit-pr19430-O0.c
    trunk/gcc/testsuite/gcc.dg/uninit-pr19430.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/uninit-6-O0.c
    trunk/gcc/testsuite/gcc.dg/uninit-6.c
    trunk/gcc/testsuite/gcc.dg/uninit-B.c
    trunk/gcc/tree-ssa.c

------- Comment #14 From Manuel López-Ibáñez 2008-08-20 22:27 -------
This is FIXED in GCC 4.4

First Last Prev Next    No search results available      Search page      Enter new bug