* [Bug ada/50294] ICE in output_constructor_regular_field, at varasm.c:4751
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
@ 2011-09-05 14:00 ` rguenth at gcc dot gnu.org
2011-09-05 14:07 ` rguenth at gcc dot gnu.org
` (10 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-05 14:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #1 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-05 13:59:44 UTC ---
http://gcc.gnu.org/ml/gcc-patches/2011-09/msg00280.html fixes the
Storage_Error issue but still ICEs because of the forced sign-extension
in output_constructor_regular_field which we do because of Ada having
"negative" DECL_FIELD_OFFSET values.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field, at varasm.c:4751
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
2011-09-05 14:00 ` [Bug ada/50294] " rguenth at gcc dot gnu.org
@ 2011-09-05 14:07 ` rguenth at gcc dot gnu.org
2011-09-05 18:33 ` [Bug ada/50294] ICE in output_constructor_regular_field ebotcazou at gcc dot gnu.org
` (9 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-05 14:07 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #2 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-05 14:06:57 UTC ---
Index: gcc/varasm.c
===================================================================
--- gcc/varasm.c (revision 178527)
+++ gcc/varasm.c (working copy)
@@ -4746,9 +4746,13 @@ output_constructor_regular_field (oc_loc
if (local->index != NULL_TREE)
{
+ /* Perform the index calculation in modulo arithmetic but
+ sign-extend the result because Ada has negative DECL_FIELD_OFFSETs
+ but we are using an unsigned sizetype. */
+ unsigned prec = TYPE_PRECISION (sizetype);
double_int idx = double_int_sub (tree_to_double_int (local->index),
tree_to_double_int (local->min_index));
- gcc_assert (double_int_fits_in_shwi_p (idx));
+ idx = double_int_sext (idx, prec);
fieldpos = (tree_low_cst (TYPE_SIZE_UNIT (TREE_TYPE (local->val)), 1)
* idx.low);
}
fixes this, but loses the check for index - min_index overflowing a HWI
(arguably that should have been detected earlier in the FEs). Fact is
we lose information when forcing offsets / indices to an unsigned type.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
2011-09-05 14:00 ` [Bug ada/50294] " rguenth at gcc dot gnu.org
2011-09-05 14:07 ` rguenth at gcc dot gnu.org
@ 2011-09-05 18:33 ` ebotcazou at gcc dot gnu.org
2011-09-06 8:32 ` rguenth at gcc dot gnu.org
` (8 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-09-05 18:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |ASSIGNED
Last reconfirmed| |2011-09-05
CC|ebotcazou at gcc dot |
|gnu.org |
AssignedTo|unassigned at gcc dot |ebotcazou at gcc dot
|gnu.org |gnu.org
Summary|ICE in |ICE in
|output_constructor_regular_ |output_constructor_regular_
|field, at varasm.c:4751 |field
Ever Confirmed|0 |1
--- Comment #3 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-09-05 18:32:35 UTC ---
Arrays with large index are a pain to support, no doubt about that.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (2 preceding siblings ...)
2011-09-05 18:33 ` [Bug ada/50294] ICE in output_constructor_regular_field ebotcazou at gcc dot gnu.org
@ 2011-09-06 8:32 ` rguenth at gcc dot gnu.org
2011-09-06 9:16 ` ebotcazou at gcc dot gnu.org
` (7 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-09-06 8:32 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #4 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-09-06 08:31:56 UTC ---
My idea with fixing the Ada issue would be to conditionally use a signed
or unsigned (sizetype) domain type. Not sure if all of the middle-end
copes well with ssizetype domains (but well, we should fix it then).
Of course that wouldn't fix use of an even larger domain type
such as Unsigned_128_T is mod 2 ** 128 and appropriate large constants.
But I see several special-cases in the Gigi code that tries to handle
overflow situations.
Thus, I think we ideally should allow any kind of integer type in
TYPE_DOMAIN, not just sizetype variants. But that's of course an even
bigger change.
Sidenote: my idea was to remove special-casings of TYPE_IS_SIZETYPE from
folders but have a few special-cases explicit in size_binop so we know
the definite context from which they are invoked (like from stor-layout).
That's much better than to expose the special-casing from random
optimization passes that happen to call into fold.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (3 preceding siblings ...)
2011-09-06 8:32 ` rguenth at gcc dot gnu.org
@ 2011-09-06 9:16 ` ebotcazou at gcc dot gnu.org
2011-09-06 9:53 ` rguenther at suse dot de
` (6 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-09-06 9:16 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-09-06 09:14:28 UTC ---
> My idea with fixing the Ada issue would be to conditionally use a signed
> or unsigned (sizetype) domain type. Not sure if all of the middle-end
> copes well with ssizetype domains (but well, we should fix it then).
Yes, IIRC I tried something like that at some point. You also mentioned in an
earlier thread that you tried to make sizetype signed. What kind of problems
did you run into? This was the original setting of the Ada compiler, so the
middle-end was able to support it, at least until relatively recently.
> Of course that wouldn't fix use of an even larger domain type
> such as Unsigned_128_T is mod 2 ** 128 and appropriate large constants.
> But I see several special-cases in the Gigi code that tries to handle
> overflow situations.
GNAT doesn't support integral types bigger than 64-bit anyway.
> Thus, I think we ideally should allow any kind of integer type in
> TYPE_DOMAIN, not just sizetype variants. But that's of course an even
> bigger change.
The signedness flip is already tricky...
> Sidenote: my idea was to remove special-casings of TYPE_IS_SIZETYPE from
> folders but have a few special-cases explicit in size_binop so we know
> the definite context from which they are invoked (like from stor-layout).
> That's much better than to expose the special-casing from random
> optimization passes that happen to call into fold.
OK, I see.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (4 preceding siblings ...)
2011-09-06 9:16 ` ebotcazou at gcc dot gnu.org
@ 2011-09-06 9:53 ` rguenther at suse dot de
2011-09-06 10:22 ` ebotcazou at gcc dot gnu.org
` (5 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: rguenther at suse dot de @ 2011-09-06 9:53 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #6 from rguenther at suse dot de <rguenther at suse dot de> 2011-09-06 09:52:38 UTC ---
On Tue, 6 Sep 2011, ebotcazou at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
>
> --- Comment #5 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-09-06 09:14:28 UTC ---
> > My idea with fixing the Ada issue would be to conditionally use a signed
> > or unsigned (sizetype) domain type. Not sure if all of the middle-end
> > copes well with ssizetype domains (but well, we should fix it then).
>
> Yes, IIRC I tried something like that at some point. You also mentioned in an
> earlier thread that you tried to make sizetype signed. What kind of problems
> did you run into? This was the original setting of the Ada compiler, so the
> middle-end was able to support it, at least until relatively recently.
I run into various diagnostic issues in the C family frontends, so I
quickly gave up.
> > Of course that wouldn't fix use of an even larger domain type
> > such as Unsigned_128_T is mod 2 ** 128 and appropriate large constants.
> > But I see several special-cases in the Gigi code that tries to handle
> > overflow situations.
>
> GNAT doesn't support integral types bigger than 64-bit anyway.
And 32-bit for 32-bit targets? sizetype is 32bits there ...
> > Thus, I think we ideally should allow any kind of integer type in
> > TYPE_DOMAIN, not just sizetype variants. But that's of course an even
> > bigger change.
>
> The signedness flip is already tricky...
Yeah, I backed off when seeing the amount of code I'd need to change
in GiGi ... esp. as I don't know the code well.
> > Sidenote: my idea was to remove special-casings of TYPE_IS_SIZETYPE from
> > folders but have a few special-cases explicit in size_binop so we know
> > the definite context from which they are invoked (like from stor-layout).
> > That's much better than to expose the special-casing from random
> > optimization passes that happen to call into fold.
>
> OK, I see.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (5 preceding siblings ...)
2011-09-06 9:53 ` rguenther at suse dot de
@ 2011-09-06 10:22 ` ebotcazou at gcc dot gnu.org
2011-11-19 21:40 ` ebotcazou at gcc dot gnu.org
` (4 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-09-06 10:22 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #7 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-09-06 10:21:42 UTC ---
> And 32-bit for 32-bit targets? sizetype is 32bits there ...
No, 64-bit type are supported universally. Of course your mileage may vary for
array types indexed with a 64-bit type...
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (6 preceding siblings ...)
2011-09-06 10:22 ` ebotcazou at gcc dot gnu.org
@ 2011-11-19 21:40 ` ebotcazou at gcc dot gnu.org
2011-11-19 21:40 ` ebotcazou at gcc dot gnu.org
` (3 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-11-19 21:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-19 21:35:48 UTC ---
> Thus the question - what should stor-layout do with domain types
> that wrap the wrong way around (i.e. are of wrong type because Ada
> turns everything into sizetype instead of [s]sizetype dependent on
> the Ada type "signedness")?
What do you mean by "Ada turns everything into sizetype" here? AFAIK the Ada
compiler behaves like the other compilers, i.e. domain types are built with
/* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
MAXVAL should be the maximum value in the domain
(one less than the length of the array).
The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT.
We don't enforce this limit, that is up to caller (e.g. language front end).
The limit exists because the result is a signed type and we don't handle
sizes that use more than one HOST_WIDE_INT. */
tree
build_index_type (tree maxval)
{
return build_range_type (sizetype, size_zero_node, maxval);
}
so are all subtypes of sizetype (gigi has create_index_type instead because it
needs to have non-shared range types and lower bounds, but it's equivalent).
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (7 preceding siblings ...)
2011-11-19 21:40 ` ebotcazou at gcc dot gnu.org
@ 2011-11-19 21:40 ` ebotcazou at gcc dot gnu.org
2011-12-01 9:34 ` rguenther at suse dot de
` (2 subsequent siblings)
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2011-11-19 21:40 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #8 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-19 21:25:17 UTC ---
Created attachment 25861
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=25861
Improved testcase
It should fail everywhere.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (8 preceding siblings ...)
2011-11-19 21:40 ` ebotcazou at gcc dot gnu.org
@ 2011-12-01 9:34 ` rguenther at suse dot de
2012-05-26 13:33 ` ebotcazou at gcc dot gnu.org
2012-05-26 13:37 ` ebotcazou at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: rguenther at suse dot de @ 2011-12-01 9:34 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #10 from rguenther at suse dot de <rguenther at suse dot de> 2011-12-01 09:34:31 UTC ---
On Sat, 19 Nov 2011, ebotcazou at gcc dot gnu.org wrote:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
>
> --- Comment #9 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2011-11-19 21:35:48 UTC ---
> > Thus the question - what should stor-layout do with domain types
> > that wrap the wrong way around (i.e. are of wrong type because Ada
> > turns everything into sizetype instead of [s]sizetype dependent on
> > the Ada type "signedness")?
>
> What do you mean by "Ada turns everything into sizetype" here? AFAIK the Ada
> compiler behaves like the other compilers, i.e. domain types are built with
>
> /* Create a type of integers to be the TYPE_DOMAIN of an ARRAY_TYPE.
> MAXVAL should be the maximum value in the domain
> (one less than the length of the array).
>
> The maximum value that MAXVAL can have is INT_MAX for a HOST_WIDE_INT.
> We don't enforce this limit, that is up to caller (e.g. language front end).
> The limit exists because the result is a signed type and we don't handle
> sizes that use more than one HOST_WIDE_INT. */
>
> tree
> build_index_type (tree maxval)
> {
> return build_range_type (sizetype, size_zero_node, maxval);
> }
>
> so are all subtypes of sizetype (gigi has create_index_type instead because it
> needs to have non-shared range types and lower bounds, but it's equivalent).
Sure, but only Ada allows user specified index types (AFAIK). At least
for the C family domains are always unsigned and fit in sizetype. The
middle-end / stor-layout code should get a "proper" domain type from the
frontends - either they canonicalize it to one that fits sizetype or
they provide a different typed domain (not sure which one is best,
but both are probably managable).
Richard.
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (9 preceding siblings ...)
2011-12-01 9:34 ` rguenther at suse dot de
@ 2012-05-26 13:33 ` ebotcazou at gcc dot gnu.org
2012-05-26 13:37 ` ebotcazou at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-05-26 13:33 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
--- Comment #11 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-05-26 13:26:01 UTC ---
Author: ebotcazou
Date: Sat May 26 13:25:55 2012
New Revision: 187914
URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=187914
Log:
PR ada/50294
* gnat.dg/array21.adb: New test.
Added:
trunk/gcc/testsuite/gnat.dg/array21.adb
Modified:
trunk/gcc/testsuite/ChangeLog
^ permalink raw reply [flat|nested] 13+ messages in thread
* [Bug ada/50294] ICE in output_constructor_regular_field
2011-09-05 13:42 [Bug ada/50294] New: ICE in output_constructor_regular_field, at varasm.c:4751 rguenth at gcc dot gnu.org
` (10 preceding siblings ...)
2012-05-26 13:33 ` ebotcazou at gcc dot gnu.org
@ 2012-05-26 13:37 ` ebotcazou at gcc dot gnu.org
11 siblings, 0 replies; 13+ messages in thread
From: ebotcazou at gcc dot gnu.org @ 2012-05-26 13:37 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=50294
Eric Botcazou <ebotcazou at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
URL| |http://gcc.gnu.org/ml/gcc-c
| |vs/2012-05/msg00038.html
Resolution| |FIXED
Target Milestone|--- |4.8.0
--- Comment #12 from Eric Botcazou <ebotcazou at gcc dot gnu.org> 2012-05-26 13:33:00 UTC ---
Not clear whether this is the most appropriate wording, but...
^ permalink raw reply [flat|nested] 13+ messages in thread