From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2975 invoked by alias); 28 Dec 2012 21:27:29 -0000 Received: (qmail 2910 invoked by uid 48); 28 Dec 2012 21:27:09 -0000 From: "steven at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c/42643] "may be used uninitialized" compiled with "-Wall -O" Date: Fri, 28 Dec 2012 21:27:00 -0000 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: normal X-Bugzilla-Who: steven at gcc dot gnu.org X-Bugzilla-Status: RESOLVED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Status CC Resolution 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 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: 2012-12/txt/msg02408.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42643 Steven Bosscher changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |RESOLVED CC| |mi+gcc at aldan dot | |algebra.com Resolution| |FIXED --- Comment #3 from Steven Bosscher 2012-12-28 21:27:07 UTC --- (In reply to comment #2) > Created attachment 26259 [details] > Live test case (file from Mozilla's NSS package) > > Even when using gcc-4.6 (more specifically gcc version 4.6.3 20111104 > (prerelease) (FreeBSD Ports Collection)), I still get a bogus warning on the > attached file, unless the optimization level is at -O3 AND the -fPIC is not > specified: > > mi@narawntapu:nss/lib/util (1778) gcc46 -Wall -O3 -c nssb64e.i > mi@narawntapu:nss/lib/util (1779) gcc46 -Wall -O2 -c nssb64e.i > nssb64e.i: In function 'NSSBase64_EncodeItem_Util': > nssb64e.i:3239:15: warning: 'out_len' may be used uninitialized in this > function [-Wuninitialized] > mi@narawntapu:nss/lib/util (1780) gcc46 -Wall -O3 -fPIC -c nssb64e.i > nssb64e.i: In function 'NSSBase64_EncodeItem_Util': > nssb64e.i:3239:15: warning: 'out_len' may be used uninitialized in this > function [-Wuninitialized] Why is this warning "bogus" in your opinion? It looks valid to me... The compiler cannot tell that out_len is initialized. The only place where out_len can pick up a value, is in the call to PL_Base64EncodeBuffer: dummy = PL_Base64EncodeBuffer (inItem->data, inItem->len, 64, out_string, max_out_len, &out_len); The compiler can't look into PL_Base64EncodeBuffer to see if a value will be assigned to "PRUint32 * output_destlen". The programmer can see that this will happen, or that otherwise NULL will be returned, but that is a really hard problem for the compiler. If you expect it to do that, you should be looking for a static checker that can do this kind of expensive analysis. There are GCC plugins that can do it. FWIW the test case of comment #0 is fixed since GCC 4.6, so closing this problem report as FIXED.