This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Fix error in clearing storage from last change


This fixes a bug my last change to this code introduces: you can have
a CONSTRUCTOR where the size is not a constant.  Existing code properly
assigns each pieces, but the code to clear memory gets it wrong.  This
could be fixed to use the expr_size again, but that fails in self-referential
cases, so it's simpler to just not do the optimization of preclearing 
in this case (when it's much less important anyway).  So I checked in this
change:

Fri Dec 24 12:34:26 1999  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	* expr.c (store_constructor): Don't call clear_storage if size is
	variable.

*** expr.c.dec22	Mon Dec 20 09:09:19 1999
--- expr.c	Thu Dec 23 08:04:39 1999
*************** store_constructor (exp, target, align, c
*** 3711,3717 ****
  	 or if we are initializing the structure to mostly zeros,
  	 clear the whole structure first.  */
!       else if ((list_length (CONSTRUCTOR_ELTS (exp))
! 		!= list_length (TYPE_FIELDS (type)))
! 	       || mostly_zeros_p (exp))
  	{
  	  if (! cleared)
--- 3711,3718 ----
  	 or if we are initializing the structure to mostly zeros,
  	 clear the whole structure first.  */
!       else if (size > 0
! 	       && ((list_length (CONSTRUCTOR_ELTS (exp))
! 		    != list_length (TYPE_FIELDS (type)))
! 		   || mostly_zeros_p (exp)))
  	{
  	  if (! cleared)
*************** store_constructor (exp, target, align, c
*** 3859,3863 ****
  	    need_to_clear = 1;
  	}
!       if (need_to_clear)
  	{
  	  if (! cleared)
--- 3860,3864 ----
  	    need_to_clear = 1;
  	}
!       if (need_to_clear && size > 0)
  	{
  	  if (! cleared)
*************** store_constructor (exp, target, align, c
*** 4041,4045 ****
         
        /* Check for all zeros.  */
!       if (elt == NULL_TREE)
  	{
  	  if (!cleared)
--- 4042,4046 ----
         
        /* Check for all zeros.  */
!       if (elt == NULL_TREE && size > 0)
  	{
  	  if (!cleared)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]