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: 103376,4eca860272d4832b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!th!lucks From: Stefan Lucks Newsgroups: comp.lang.ada Subject: Re: Static vs dynamic evaluation anomaly? Date: Fri, 9 Feb 2007 08:57:52 +0100 Organization: InterNetNews at News.BelWue.DE (Stuttgart, Germany) Message-ID: References: <12shen4qjhv41a7@corp.supernews.com> <1170792077.235994.10900@q2g2000cwa.googlegroups.com> <87d54mguco.fsf@ludovic-brenta.org> <1170843700.7656.47.camel@localhost.localdomain> <1170866664.465875.309930@v45g2000cwv.googlegroups.com> <1170874545.463017.180430@j27g2000cwj.googlegroups.com> <1170897971.419567.78410@a34g2000cwb.googlegroups.com> <2cKyh.337215$FQ1.333812@attbi_s71> NNTP-Posting-Host: th.informatik.uni-mannheim.de Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Trace: news.BelWue.DE 1171007875 214 134.155.91.85 (9 Feb 2007 07:57:55 GMT) X-Complaints-To: news@news.belwue.de NNTP-Posting-Date: Fri, 9 Feb 2007 07:57:55 +0000 (UTC) In-Reply-To: <2cKyh.337215$FQ1.333812@attbi_s71> Xref: g2news2.google.com comp.lang.ada:9168 Date: 2007-02-09T08:57:52+01:00 List-Id: On Thu, 8 Feb 2007, Jeffrey R. Carter wrote: > Adam Beneschan wrote: > > Hmmm. This is certainly not the way I would expect a "perform this > > check" or "don't perform this check" flag to work. To me, if the [...] > I understand your logic; I'm not even saying I disagree. But perhaps the > compiler writer's view is that it's OK to store the larger value as long > as the extra bits are never used. Then the error is in the I/O, which is > using the extra bits. This is a valid point -- except that the extra bits are not just used by the IO, but also, e.g., for comparisons: with Ada.Text_IO; use Ada.Text_IO; procedure test272 is type Six_Bits is mod 2**6; X: constant Six_Bits := 31; Z: constant Integer := 31; T: integer; begin for J in 0..9 loop T := (Integer(X) * 2**Integer(J)) mod Six_Bits'Modulus; Put (Integer 'Image (J) & Six_Bits'Image (X * 2**J) & Integer 'Image (T) ); if (X * 2**J) = Six_Bits(T) then Put_Line(" equal"); else Put_Line(" different!!!"); end if; end loop; end test272; With "gnatmake" (no option) or "gnatmake -gnatp" I get wrong results: ./test272 0 31 31 equal 1 62 62 equal 2 124 60 different!!! 3 248 56 different!!! 4 240 48 different!!! 5 224 32 different!!! 6 192 0 different!!! 7 128 0 different!!! 8 0 0 equal 9 0 0 equal -- Stefan Lucks Th. Informatik, Univ. Mannheim, 68131 Mannheim, Germany e-mail: lucks@th.informatik.uni-mannheim.de home: http://th.informatik.uni-mannheim.de/people/lucks/ ------ I love the taste of Cryptanalysis in the morning! ------