C++: Internal compiler error
Mark Mitchell
mark@codesourcery.com
Mon Apr 24 10:43:00 GMT 2000
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;
+ }
+
I'm not sure this is quite good enough. Either it isn't, or
compute_array_index_type is doing a lot more work than it needs to!
For instance, does this handle `const int I = 7' as an array bound?
Similarly `(int) (int) I'?
By the way, why does compute_array_index_type convert the argument to
ssizetype? Array index types would seem more naturally unsigned to
me. And what if the original bound had type `long long'? Aren't we
then truncating the array?
I wonder if you shouldn't check for this problem later in the game,
after the array type is created a few lines below your patch. Then,
all you have to do is check that the TYPE_DOMAIN is TREE_CONSTANT, and
fix up the type (for error-reporting purposes) if not.
--
Mark Mitchell mark@codesourcery.com
CodeSourcery, LLC http://www.codesourcery.com
More information about the Gcc-bugs
mailing list