Branch: Tag:

2015-02-06

2015-02-06 20:28:38 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler: Fixed over-optimization of initialization to false.

This optimization may only be done when the value being assigned
actually is a zero.

Also adds a corresponding diagnostic.

1691:    * NB: The compat test is due to that this changes the semantics    * of calling __INIT() by hand.    */ -  if (SAFE_IS_ZERO(&$5->u.sval) && -  !SUBTYPEOF($5->u.sval) && +  if ((TYPEOF($5->u.sval) == PIKE_T_INT) && !SUBTYPEOF($5->u.sval) && +  !$5->u.sval.u.integer &&    !IDENTIFIER_IS_ALIAS(ID_FROM_INT(Pike_compiler->new_program,    $<number>4)->identifier_flags)) {    /* NB: Inherited variables get converted into aliases by    * define_variable, and we need to support clearing    * of inherited variables.    */ -  + #ifdef PIKE_DEBUG +  if (l_flag > 5) { +  fprintf(stderr, +  "Ignoring initialization to zero for variable %s.\n", +  $2->u.sval.u.string->str); +  } + #endif /* PIKE_DEBUG */    free_node($5);    $5 = NULL;    }