This is the mail archive of the gcc-bugs@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]

Your change to expr.c



This change:

Thu Oct 28 18:06:50 1999  Richard Kenner  <kenner@vlsi1.ultra.nyu.edu>

	(readonly_fields_p): New function.
	(expand_expr, case INDIRECT_REF): Call it if LHS.

is buggy.  Did this survive a bootstrap before you checked it in?  It
fails for me building libgcc2.  It's our established policy to do a
full bootstrap when changing stuff that could affect the compiler as a
whole.

In particular, here's readonly_fields:

  static int
  readonly_fields_p (type)
       tree type;
  {
    tree field;

    for (field = TYPE_FIELDS (type); field != 0; field = TREE_CHAIN (field))
      if (TREE_READONLY (field)
	  || (TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE
	      && readonly_fields_p (TREE_TYPE (field))))
	return 1;

    return 0;
  }

yields infinite recursion since a TYPE_DECL (on the TYPE_FIELDS list)
can refer to TYPE (or a derived class thereof) thereby causing an
infinite recursion.  Similarly a static data member (VAR_DECL) can
have the same type as TYPE.  I'm testing the obvious fix (skip fields
that are not FIELD_DECLs). 

I'm pretty nervous about the way this function is being used, too:

	/* If we are writing to this object and its type is a record with
	   readonly fields, we must mark it as readonly so it will
	   conflict with readonly references to those fields.  */
	if (modifier == EXPAND_MEMORY_USE_WO
	    && TREE_CODE (type) == RECORD_TYPE && readonly_fields_p (type))
	  RTX_UNCHANGING_P (temp) = 1;

That looks to me like the entire object written to is becoming
RTX_UNCHANGING_P if any of its fields are.  But, it's still possible
to change other fields in the object.  IMO, RTX_UNCHANGING_P should be
set only if *all* the fields are readonly.

--
Mark Mitchell                   mark@codesourcery.com
CodeSourcery, LLC               http://www.codesourcery.com


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