[PATCH] Fix internal error on small array with negative lower bound

2023-05-18 Thread Eric Botcazou via Gcc-patches
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_const

Re: [PATCH] Fix internal error on small array with negative lower bound

2023-05-18 Thread Richard Biener via Gcc-patches
On Thu, May 18, 2023 at 11:51 AM Eric Botcazou via Gcc-patches 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 wo

Re: [PATCH] Fix internal error on small array with negative lower bound

2023-05-18 Thread Eric Botcazou via Gcc-patches
> 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

Re: [PATCH] Fix internal error on small array with negative lower bound

2023-05-18 Thread Richard Biener via Gcc-patches
> Am 18.05.2023 um 19:44 schrieb Eric Botcazou : > >  >> >> 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