On Thu, May 18, 2023 at 11:51 AM Eric Botcazou via Gcc-patches <gcc-patches@gcc.gnu.org> wrote: > > Hi, > > Ada supports arrays with negative indices, although the internal index type is > sizetype like in other languages, which is unsigned. This means that negative > values are represented by very large numbers, which works with a bit of care. > The attached test exposes a small loophole in output_constructor_bitfield. > > Tested on x86-64/Linux, OK for the mainline?
Would it be better to use wi::to_uhwi (wi::to_wide (local->index) - wi::to_wide (local->min_index)) to honor the actual sign of the indices? I think nothing forbids frontends to use a signed TYPE_DOMAIN here? But the difference should be always representable in an unsigned value of course. > > 2023-05-18 Eric Botcazou <ebotca...@adacore.com> > > * varasm.cc (output_constructor_bitfield): Call tree_to_uhwi instead > of tree_to_shwi on array indices. Minor tweaks. > > > 2023-05-18 Eric Botcazou <ebotca...@adacore.com> > > * gnat.dg/specs/array6.ads: New test. > > -- > Eric Botcazou