Patchwork [pph] Initialize cache_ix in all paths in pph_start_record (issue4642045)

login
register
mail settings
Submitter Gab Charette
Date June 18, 2011, 1:29 a.m.
Message ID <20110618012929.167F61C11F2@gchare.mtv.corp.google.com>
Download mbox | patch
Permalink /patch/100887/
State New
Headers show

Comments

Gab Charette - June 18, 2011, 1:29 a.m.
Clarified comment from v1 of this patch.

2011-06-17  Gabriel Charette  <gchare@google.com>

	* 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

Patch

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 in a given build as
+	 it will complain that " 'ix' may be used uninitialized".  */
+      *cache_ix = -1;
+    }
 
   return marker;
 }