This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] for PRs 27639 and 26719


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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]