Patchwork Initialize previous in read_state_param_structs

login
register
mail settings
Submitter Alexandre Oliva
Date May 30, 2011, 9:51 a.m.
Message ID <ork4d8348z.fsf@livre.localdomain>
Download mbox | patch
Permalink /patch/97898/
State New
Headers show

Comments

Alexandre Oliva - May 30, 2011, 9:51 a.m.
Bootstrap-O3 complains about uninitialized uses of this variable in
gengtype-state.c.  The variable can never actually be used before
initialization, but GCC is not smart enough to realize that.
read_state_structures, just before the function at hand, has a similar
loop and it zero-initializes both head and previous, so I adjusted the
affected function to follow the same pattern and avoid the bogus
warning.  Regstrapped on x86_64-linux-gnu and i686-pc-linux-gnu.  Ok to
install?
Bernd Schmidt - May 30, 2011, 10:26 a.m.
On 05/30/2011 11:51 AM, Alexandre Oliva wrote:
> Bootstrap-O3 complains about uninitialized uses of this variable in
> gengtype-state.c.  The variable can never actually be used before
> initialization, but GCC is not smart enough to realize that.
> read_state_structures, just before the function at hand, has a similar
> loop and it zero-initializes both head and previous, so I adjusted the
> affected function to follow the same pattern and avoid the bogus
> warning.  Regstrapped on x86_64-linux-gnu and i686-pc-linux-gnu.  Ok to
> install?

Ok. Alternatively you could fix the warning and shorten the code using
the pprev trick.


Bernd
Jack Howarth - June 4, 2011, 3:16 a.m.
On Mon, May 30, 2011 at 12:26:50PM +0200, Bernd Schmidt wrote:
> On 05/30/2011 11:51 AM, Alexandre Oliva wrote:
> > Bootstrap-O3 complains about uninitialized uses of this variable in
> > gengtype-state.c.  The variable can never actually be used before
> > initialization, but GCC is not smart enough to realize that.
> > read_state_structures, just before the function at hand, has a similar
> > loop and it zero-initializes both head and previous, so I adjusted the
> > affected function to follow the same pattern and avoid the bogus
> > warning.  Regstrapped on x86_64-linux-gnu and i686-pc-linux-gnu.  Ok to
> > install?
> 
> Ok. Alternatively you could fix the warning and shorten the code using
> the pprev trick.
> 
> 
> Bernd

Alexandre,
    Since your original patch was approved, are you checking in
http://gcc.gnu.org/ml/gcc-patches/2011-05/msg02304.html? Currently the
-O3 bootstrap is still broken without it.
           Jack
Alexandre Oliva - June 4, 2011, 10:16 a.m.
On Jun  4, 2011, Jack Howarth <howarth@bromo.med.uc.edu> wrote:

>     Since your original patch was approved, are you checking in
> http://gcc.gnu.org/ml/gcc-patches/2011-05/msg02304.html? Currently the
> -O3 bootstrap is still broken without it.

This one was already installed, but there's another problem that
prevents -O3 bootstrap still pending review.

http://gcc.gnu.org/ml/gcc-patches/2011-05/msg02301.html

Patch

for  gcc/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	* gengtype-state.c (read_state_params_structs): Initialize
	previous.

Index: gcc/gengtype-state.c
===================================================================
--- gcc/gengtype-state.c.orig	2011-05-18 05:02:28.341594395 -0300
+++ gcc/gengtype-state.c	2011-05-18 05:02:32.710587356 -0300
@@ -2137,7 +2137,7 @@  read_state_param_structs (type_p *param_
   int nbparamstructs = 0;
   int countparamstructs = 0;
   type_p head = NULL;
-  type_p previous;
+  type_p previous = NULL;
   type_p tmp;
   struct state_token_st *t0 = peek_state_token (0);
   struct state_token_st *t1 = peek_state_token (1);