From patchwork Fri Jun 17 22:49:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gab Charette X-Patchwork-Id: 100873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 4C777B6FDD for ; Sat, 18 Jun 2011 08:49:41 +1000 (EST) Received: (qmail 5762 invoked by alias); 17 Jun 2011 22:49:38 -0000 Received: (qmail 5745 invoked by uid 22791); 17 Jun 2011 22:49:35 -0000 X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from smtp-out.google.com (HELO smtp-out.google.com) (216.239.44.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 17 Jun 2011 22:49:21 +0000 Received: from kpbe17.cbf.corp.google.com (kpbe17.cbf.corp.google.com [172.25.105.81]) by smtp-out.google.com with ESMTP id p5HMnKAF008216; Fri, 17 Jun 2011 15:49:20 -0700 Received: from gchare.mtv.corp.google.com (gchare.mtv.corp.google.com [172.18.111.122]) by kpbe17.cbf.corp.google.com with ESMTP id p5HMnIt9015242; Fri, 17 Jun 2011 15:49:19 -0700 Received: by gchare.mtv.corp.google.com (Postfix, from userid 138564) id BA4771C1E31; Fri, 17 Jun 2011 15:49:18 -0700 (PDT) To: reply@codereview.appspotmail.com, crowl@google.com, dnovillo@google.com, gcc-patches@gcc.gnu.org Subject: [pph] Initialize cache_ix in all paths in pph_start_record (issue4642045) Message-Id: <20110617224918.BA4771C1E31@gchare.mtv.corp.google.com> Date: Fri, 17 Jun 2011 15:49:18 -0700 (PDT) From: gchare@google.com (Gabriel Charette) X-System-Of-Record: true X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Read the comment in the diff for all the details. I found this while working on my current patch, adding some assertion at the end of the function would create a new build error and moving it around in the function would stop showing the error. I discussed this with Collin and Jeff and it appears that the compiler changes it's inlining decisions based on very picky details. In this particular case, inlining the function resulted in an error. Tested with bootstrap build and pph regression testing. 2011-06-17 Gabriel Charette * gcc/cp/pph-streamer-in.c (pph_start_record): Initialize cache_ix in all paths. --- This patch is available for review at http://codereview.appspot.com/4642045 diff --git a/gcc/cp/pph-streamer-in.c b/gcc/cp/pph-streamer-in.c index b3c2ac9..186100f 100644 --- a/gcc/cp/pph-streamer-in.c +++ b/gcc/cp/pph-streamer-in.c @@ -204,7 +204,15 @@ pph_start_record (pph_stream *stream, unsigned *cache_ix) if (marker == PPH_RECORD_START || marker == PPH_RECORD_SHARED) *cache_ix = pph_in_uint (stream); else - gcc_assert (marker == PPH_RECORD_END); + { + gcc_assert (marker == PPH_RECORD_END); + /* Initialize CACHE_IX to an invalid index. Even though this + is never used in practice, the compiler will throw an error + if the optimizer inlines this function and discards the asserts + in a given build as it will complain that " 'ix' may be used + unititialized". */ + *cache_ix = -1; + } return marker; }