C++: Internal compiler error
Martin v. Loewis
martin@loewis.home.cs.tu-berlin.de
Mon Apr 24 11:42:00 GMT 2000
> + /* 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'?
Both work fine. cp_convert comes back with a constant in these cases,
as it uses decl_constant_value if it find that the declaration is a
constant expression. I only need the check for 'integral constant',
not the actual value.
> By the way, why does compute_array_index_type convert the argument to
> ssizetype?
I don't know. It originates from the old grokdeclarator fragment
/* The index is a signed object `sizetype' bits wide. */
tree index_type = signed_type (sizetype);
which predates egcs.
> And what if the original bound had type `long long'? Aren't we then
> truncating the array?
No, it gives the error "overflow in array dimension".
> 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.
I think the type cannot be changed afterwards, since it is already
hashed. Also, in this case, it would produce two diagnostic messages
for the same problem under -pedantic (first would be a pedwarn that
VLAs are not standard C++, and then it would cp_error that they won't
work at all as members).
Regards,
Martin
More information about the Gcc-bugs
mailing list