This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch] for PRs 27639 and 26719
- From: Duncan Sands <duncan dot sands at math dot u-psud dot fr>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Eric Botcazou <ebotcazou at adacore dot com>, "Richard Guenther" <richard dot guenther at gmail dot com>, "Zdenek Dvorak" <rakdver at atrey dot karlin dot mff dot cuni dot cz>, sebastian dot pop at cri dot ensmp dot fr, rguenther at suse dot de
- Date: Sun, 25 Jun 2006 22:06:30 +0200
- Subject: Re: [patch] for PRs 27639 and 26719
- References: <20060520192624.GA28713@atrey.karlin.mff.cuni.cz> <84fc9c000606250352p423ff607u73b41de59a7abe55@mail.gmail.com> <200606251307.21077.ebotcazou@adacore.com>
Hi Eric,
> > Uh, I would guess a safe answer from nowrap_type_p is false, so you
> > need to put some reasoning behind that (integer) types with a base
> > type do not wrap.
>
> My understanding is that a value may wrap in the base type but never in the
> subtype alone.
I missed the start of this thread, so maybe am completely missing the point,
but... since a subtype may be equal to the basetype, things may wrap in the
subtype too, for example the following is OK.
procedure X is
type M is mod 2; -- range is 0 .. 1
subtype N is M range 0 .. 1;
A : N := 1;
begin
A := A + 1;
end;
Worse, you cannot always know at compile time whether a subtype is strictly
smaller than the base type or not. The following is also ok:
procedure Y is
type M is mod 2;
procedure P (Max : M) is
subtype N is M range 0 .. Max; -- range is 0 .. 1 when Max = 1
A : N := Max;
begin
A := A + 1;
end;
begin
P (1);
end;
However, since calculations are always done in the base type, considerations
on whether subtypes are wrapping or not should be irrelevant, which probably
means we are each talking about completely different things...
> > Apart from that, you seem to rely on "optimization" (nowrap_type_p returning
> > true) to avoid the bug?
>
> Not sure it's an optimization. But perhaps tweaking convert_affine_scev would
> indeed be better.
Ciao,
D.