From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7583 invoked by alias); 10 Mar 2014 16:17:45 -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 Received: (qmail 7563 invoked by uid 48); 10 Mar 2014 16:17:42 -0000 From: "msebor at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/60488] New: missing -Wmaybe-uninitialized on a conditional with goto Date: Mon, 10 Mar 2014 16:17:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c X-Bugzilla-Version: 4.8.2 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: msebor at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2014-03/txt/msg00795.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60488 Bug ID: 60488 Summary: missing -Wmaybe-uninitialized on a conditional with goto Product: gcc Version: 4.8.2 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c Assignee: unassigned at gcc dot gnu.org Reporter: msebor at gmail dot com The -Wmaybe-uninitialized option is documented like so: "For an automatic variable, if there exists a path from the function entry to a use of the variable that is initialized, but there exist some other paths for which the variable is not initialized, the compiler emits a warning if it cannot prove the uninitialized paths are not executed at run time." In the program below, when f(&a) returns zero, the variable b is considered to have been initialized by the call to f(&b) when it's used as the argument in the first call to g(b). However, when f(&a) returns non-zero, the variable b is used uninitialized in the second call to g(b). Therefore, there exists a path through the function where b is used initialized as well as one where it's used uninitialized. Thus, GCC should issue a warning. It, however, does not. $ cat t.c && gcc -O2 -Wuninitialized -Wmaybe-uninitialized -c -o/dev/null t.c int f (int**); void g (int*); int foo (void) { int *a, *b; if (f (&a) || f (&b)) goto end; g (a); g (b); return 0; end: g (b); return 1; }