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 layout_decl abort on zero sized types.


We would abort on this test case, derived from a bit in glibc.

struct foo
{
  long x;
  char y;
  long boom[0];
};

I've checked this in as gcc.c-torture/compile/20000319-1.c.

Bootstrapped alphaev67-dec-linux-gnu.



r~

	* stor-layout.c (layout_decl): Don't abort on any zero sized decl.

Index: stor-layout.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/stor-layout.c,v
retrieving revision 1.57
diff -u -p -d -r1.57 stor-layout.c
--- stor-layout.c	2000/03/15 00:12:37	1.57
+++ stor-layout.c	2000/03/19 11:51:22
@@ -308,17 +308,6 @@ layout_decl (decl, known_align)
     {
       HOST_WIDE_INT spec_size;
 
-      /* The front-end may set the explicit width of the field, so its
-	 size may not be the same as the size of its type.  This happens
-	 with bitfields, of course (an `int' bitfield may be only 2 bits,
-	 say), but it also happens with other fields.  For example, the
-	 C++ front-end creates zero-sized fields corresponding to empty
-	 base classes, and depends on layout_type setting
-	 DECL_FIELD_BITPOS correctly for the field.  */
-      if (integer_zerop (DECL_SIZE (decl)) 
-	  && DECL_NAME (decl) != NULL_TREE)
-	abort ();
-
       /* Size is specified in number of bits.  */
       spec_size = TREE_INT_CST_LOW (DECL_SIZE (decl));
       if (spec_size % BITS_PER_UNIT == 0)

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