On Fri, Jun 6, 2025 at 10:31 AM Eric Botcazou <botca...@adacore.com> wrote:
>
> Hi,
>
> the attached Ada testcase triggers an assertion failure in size_binop_loc:
>
> +===========================GNAT BUG DETECTED==============================+
> | 16.0.0 20250605 (experimental) [master r16-1173-gda96bdfff08] (x86_64-suse-
> linux) GCC error:|
> | in size_binop_loc, at fold-const.cc:2091                                 |
> | Error detected around aggr7.ads:9:36
>
>   gcc_assert (int_binop_types_match_p (code, TREE_TYPE (arg0),
>                                        TREE_TYPE (arg1)));
>
> because the very old code for ARRAY_TYPE in store_constructor is confused in
> the case where it cannot perform static host-based arithmetics on offsets.
>
> But the root cause is that it performs all the calculations in signed sizetype
> while TYPE_DOMAIN is supposed to be a subtype of (unsigned) sizetype, even for
> signed index types in Ada like in the testcase, so the code takes the dynamic
> path instead of the static one for negative indices.
>
> Bootstrapped/regtested on x86-64/Linux, OK for the mainline?

OK.

Thanks,
Richard.

>
> 2025-06-06  Eric Botcazou  <ebotca...@adacore.com>
>
>         * expr.cc (store_constructor) <ARRAY_TYPE>: Perform the static
>         host-based arithmetics on offsets in (unsigned) sizetype.
>
>
> 2025-06-06  Eric Botcazou  <ebotca...@adacore.com>
>
>         * gnat.dg/specs/aggr7.ads: New test.
>
> --
> Eric Botcazou

Reply via email to