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]

C++: Internal compiler error


> temp.cpp:19: Internal compiler error in `find_function_data', at
> function.c:542

Thanks for your bug report. Below is the patch. With this patch, the
compiler reports

temp.cpp:11: size of member `data' is not constant

which was the cause of the problem.

Regards,
Martin

2000-04-24  Martin v. L÷wis  <loewis@informatik.hu-berlin.de>

	* decl.c (grokdeclarator): Reject VLAs as members.

// Build don't link:
int i = 4;
struct S{
  char c[i];      // ERROR - size not constant
  int h;
  int foo(){
    return h;
  }
};

int main()
{
  S x;
  int i = x.foo();
}

Index: decl.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/decl.c,v
retrieving revision 1.594
diff -u -p -r1.594 decl.c
--- decl.c	2000/04/24 06:41:16	1.594
+++ decl.c	2000/04/24 12:20:55
@@ -10351,6 +10351,17 @@ grokdeclarator (declarator, declspecs, d
 
 	    declarator = TREE_OPERAND (declarator, 0);
 
+	    /* VLAs never work as fields. */
+	    if (decl_context == FIELD && size != NULL_TREE
+		&& !processing_template_decl
+		&& !TREE_CONSTANT (cp_convert (sizetype, size)))
+	      {
+		cp_error ("size of member `%D' is not constant", dname);
+		/* Proceed with arbitrary constant size, so that offset
+		   computations don't get confused. */
+		size = integer_one_node;
+	      }
+
 	    type = create_array_type_for_decl (dname, type, size);
 	    ctype = NULL_TREE;
 	  }

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