From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22738 invoked by alias); 15 Jul 2011 11:01:11 -0000 Received: (qmail 22729 invoked by uid 22791); 15 Jul 2011 11:01:11 -0000 X-SWARE-Spam-Status: No, hits=-2.8 required=5.0 tests=ALL_TRUSTED,AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from localhost (HELO gcc.gnu.org) (127.0.0.1) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 15 Jul 2011 11:00:31 +0000 From: "giecrilj at stegny dot 2a.pl" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/49754] Let gcc warn about all uninitialized variables X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: giecrilj at stegny dot 2a.pl X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Date: Fri, 15 Jul 2011 11:01:00 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2011-07/txt/msg01235.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49754 --- Comment #5 from Christopher Yeleighton 2011-07-15 11:00:28 UTC --- (In reply to comment #3) > (In reply to comment #2) > > Since (x) is uninitialized, so is (x.i). > > But what if x.i gets initialized, is x still uninitialized? If (x.i) denotes an object type and the initial value means "x is empty" then x is initialized. > > struct X { int i; }; > struct Y { int i; int j; }; > > int main() > { > X x; > x.i = 0; // is 'x' initialized now? > Y y; > y.i = 0; // is 'y' initialized now? > y.j = 0; // is 'y' initialized now? > } > > > It would be possible to track the initialization of each subobject *and* the > aggregate, but it would be more overhead I have already bumped into this using arrays, where GCC does emit a warning although it should not: int a [02]; for (a [0] = 0;;) if (a [0]) printf ("%d", +a [1]); else a [0] = a [1] = 01;