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]

[patch] Fix ICE on aligned architectures


Hi,
the attached patch fixes an ICE on the attached test case, which manifests
on architectures with store alignment restrictions -- in my case sparc.

What happens is that TYPE_ALIGN (t) gets set to 1 bit in make node, and
remains that way for incomplete types. Trying to write through a pointer
to incomplete can then fail. The patch sets the default TYPE_ALIGN to
be that of char_type_node, if it exists, zero otherwise.

This also appears to fix compile/20000606-1.c which is a similar
problem involving an external global of initialy incomplete type and
compile/20000609-1.c, but I don't understand why.

booted and tested on sparc-sun-solaris2.7. ok?

nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
2000-10-24  Nathan Sidwell  <nathan@codesourcery.com>

	* tree.c (make_node, case 't'): Set alignment to that of
	char_type_node.
	* expr.c (move_by_pieces_ninsns): Abort if some length remains.
	
Index: tree.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/tree.c,v
retrieving revision 1.166
diff -c -3 -p -r1.166 tree.c
*** tree.c	2000/10/23 04:40:25	1.166
--- tree.c	2000/10/24 10:22:10
*************** make_node (code)
*** 438,444 ****
  
      case 't':
        TYPE_UID (t) = next_type_uid++;
!       TYPE_ALIGN (t) = 1;
        TYPE_USER_ALIGN (t) = 0;
        TYPE_MAIN_VARIANT (t) = t;
        TYPE_ATTRIBUTES (t) = NULL_TREE;
--- 438,444 ----
  
      case 't':
        TYPE_UID (t) = next_type_uid++;
!       TYPE_ALIGN (t) = char_type_node ? TYPE_ALIGN (char_type_node) : 0;
        TYPE_USER_ALIGN (t) = 0;
        TYPE_MAIN_VARIANT (t) = t;
        TYPE_ATTRIBUTES (t) = NULL_TREE;
Index: expr.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/expr.c,v
retrieving revision 1.271
diff -c -3 -p -r1.271 expr.c
*** expr.c	2000/10/23 04:40:25	1.271
--- expr.c	2000/10/24 10:22:15
*************** move_by_pieces_ninsns (l, align)
*** 1536,1541 ****
--- 1536,1543 ----
        max_size = GET_MODE_SIZE (mode);
      }
  
+   if (l)
+     abort ();
    return n_insns;
  }
  
/* Copyright (C) 2000  Free Software Foundation  */
/* Contributed by Nathan Sidwell <nathan@codesourcery.com> */

typedef __SIZE_TYPE__ size_t;

extern void *memset(void *, int, size_t);

struct Baz;

void quux(struct Baz *context)
{
  memset(context, 0, 4);
}

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