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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,76e8d825615718a X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!s9g2000yqa.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: Ada.Containers Hash function for a set of small integers Date: Mon, 26 Apr 2010 21:50:19 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <50701baa-7c05-450c-a42d-c699516ddc00@t14g2000prm.googlegroups.com> <0590cf17-12ea-401d-9dc3-02365139b37e@p35g2000prf.googlegroups.com> <06f5335a-f686-4af1-893a-55517abe8d1a@s21g2000pri.googlegroups.com> NNTP-Posting-Host: 80.156.44.178 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1272343819 31812 127.0.0.1 (27 Apr 2010 04:50:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 27 Apr 2010 04:50:19 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s9g2000yqa.googlegroups.com; posting-host=80.156.44.178; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; WOW64; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.04506.648),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:11198 Date: 2010-04-26T21:50:19-07:00 List-Id: > > =A0 =A0 =A0 =A0 =A0Result :=3D Result xor M (Integer'Pos (X) mod 2**31)= ; > > =A0 =A0 =A0 =A0 =A0-- =A0No warning (and executes as I had expected) > > =A0 =A0 =A0 =A0 =A0Put_Line ("result:" & M'Image (Result)); > > =A0 =A0 =A0 exception > > =A0 =A0 =A0 =A0 =A0when others =3D> Put_Line ("exception c"); > > =A0 =A0 =A0 end; > about the zero divisor. The Aonix ObjectAda 7.2 compiler ... > gives an error at the third block (95LRM4.9(35)). I'm no language lawyer, but I'll give it a try. RM95 4.9(35): If the expression is not part of a larger static expression, then its value shall be within the base range of its expected type. Otherwise, the value may be arbitrarily large or small. RM TC1 AM1 4.9(35/2) {AI95-00269-01} If the expression is not part of a larger static expression *and the expression is expected to be of a single specific type*, then its value shall be within the base range of its expected type. Otherwise, the value may be arbitrarily large or small. Since Aonix quotes 95RM4.9(35), it must be a pure Ada95 compiler. 2**31 is not part or a larger static expression. The further condition of being of a single specific type (which is not the case here, the expected type is any integer type) was added later. So Aonix is correct, and so is GNAT, if the latter is new enough to obey AM1.