This is the mail archive of the gcc@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: Ada subtypes and base types


On 3/16/06, Richard Guenther <richard.guenther@gmail.com> wrote:
> On 3/16/06, Laurent GUERBY <laurent@guerby.net> wrote:
> > procedure T2 is
> >    type R is range 1 .. 10;
> >    type T is array (R) of Integer;
> >    I : R;
> >    X : T;
> > begin
> >    X (I) := 0;
> > end T2;
> >
> > The Ada FE will insert an explicit check, as seen when using
> > gcc -c -gnatdg t2.adb:
> >
> >    [constraint_error when not (interfaces__unsigned_32!(i) >= 1 and then
> >      interfaces__unsigned_32!(i) <= 10) "invalid data"]
> >
> > Will the ME or FE remove the check?
>
> Yes it will - as we see from -O0 -fdump-tree-original:
>
>   if ((interfaces__unsigned_32) i == 0 || i > 10)
>     {
>       __gnat_rcheck_06 ("t2.adb", 7);
>     }
>   else
>     {
>
>     }
>
> it uses a regular NOP/CONVERT_EXPR which VRP happily will see through
> (validly so).
> It also misses the conversion for the i>10 check completely.  It needs to print
>
>   if (VIEW_CONVERT_EXPR<interfaces__unsigned_32>(i) == 0
>      || VIEW_CONVERT_EXPR<interfaces__unsigned_32>(i) > 10)
>
> So, this is a bug in gigi here.

The above was for 4.1.0 - with mainline gigi now generates

  if (i == 0 || i > 10)
    {
      __gnat_rcheck_06 ("t2.adb", 7);
    }
  else
    {

    }
  x[(<unnamed type>) (t2__TrB) i]{lb: 1 sz: 4} = 0;

huh?  That's even more bogus.

Richard.


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