This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
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
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
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
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).
Suspending as it is fixed on the tree-ssa branch.
Leaving as suspending as someone needs to update the testcase.
Fixed for 3.5.0 by the merge of the tree-ssa.
*** Bug 17191 has been marked as a duplicate of this bug. ***
*** Bug 17172 has been marked as a duplicate of this bug. ***
(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
Some analysis http://gcc.gnu.org/ml/gcc/2007-08/msg00271.html
Non-regressions should not have a target milestone set.
Patch: http://gcc.gnu.org/ml/gcc-patches/2008-08/msg00696.html Comments welcome!
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
This is FIXED in GCC 4.4