From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,2478ea1b71f848e3 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,UTF8 Received: by 10.66.81.195 with SMTP id c3mr9693181pay.44.1351530204015; Mon, 29 Oct 2012 10:03:24 -0700 (PDT) Path: 6ni49882pbd.1!nntp.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!ctu-peer!news.nctu.edu.tw!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: =?utf-8?Q?Yannick_Duch=C3=AAne_=28Hibou57?= =?utf-8?Q?=29?= Newsgroups: comp.lang.ada Subject: Re: =?utf-8?B?R05BVCBkb2luZyBtYWNyb+KAkWV4cGFuc2lvbj8gKFByZS9Qb3N0IGNvbmQ=?= =?utf-8?B?aXRpb25zKQ==?= Date: Wed, 24 Oct 2012 18:40:58 +0200 Organization: Ada @ Home Message-ID: References: NNTP-Posting-Host: qMb93YQAAEXAn86i0hBe/g.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Opera Mail/12.02 (Linux) X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes Content-Transfer-Encoding: Quoted-Printable Date: 2012-10-24T18:40:58+02:00 List-Id: Le Fri, 19 Oct 2012 01:44:29 +0200, Yannick Duch=C3=AAne (Hibou57) = a =C3=A9crit: > Is this GNAT doing macro=E2=80=91expansion for generics, or me missing= some = > trick of Ada 2012? > Really has issue with DbC (Design by Contract). Here is another bug I = encountered. Note: I know source snippets exposing bugs are boring thing= s = to read, but I will post it anyway, if ever that can be of interest for = = someone. I will post two or three other cases, around the same snippet. = = Obviously, this does not stand for the reliable, it was simplified down = as = much as possible, as the purpose is two talk about the issue. -- bug1.adb procedure Bug1 is package P is type A_Type is mod 256; type I_Type is range 0 .. 4_000; type S_Type is array (I_Type range <>) of A_Type; type T (I, J : I_Type) is record S : S_Type (1 .. J); K : I_Type :=3D 1; end record with Predicate =3D> (T.K <=3D T.I) and (T.I <=3D T.J); end P; package body P is -- Useless, but see below, -- in the second comments -- about a variation on the bug. end P; E : P.T (I =3D> 2_000, J =3D> 2_006); begin null; end Bug1; ## First bug Compiled with GNAT 4.6, then executed, I get this: raised CONSTRAINT_ERROR : bug1.adb:16 invalid data While `K` which is (or should) be initialized to 1, is really (or should= ) = lower or equal to `I`, which is 2 000. ## Variation Interesting variation: remove the useless package body given to `P`. Now= , = compiling fails, with this error: bug1.adb:16: operator for type "I_Type" defined at line 6 is not = directly visible So it says operators of `I_Type` are not visible from the location of th= e = expression `(T.K <=3D T.I)`; that's obviously buggy. The latter is similar to the one of the first post. Surprisingly, it = depends on the presence of absence of th useless package body. Another variation, exposing two other bugs (if my mind is right), to com= e = later (just the time to me to simplify it down). -- = =E2=80=9CSyntactic sugar causes cancer of the semi-colons.=E2=80=9D [1] =E2=80=9CStructured Programming supports the law of the excluded muddle.= =E2=80=9D [1] [1]: Epigrams on Programming =E2=80=94 Alan J. =E2=80=94 P. Yale Univers= ity