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,4158e4de0999807a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.vmunix.org!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: GNAT 4.0 strange behaviour Date: Mon, 12 Sep 2005 06:11:13 +0100 Organization: Pushface Message-ID: References: <4324c57b$0$17248$8fcfb975@news.wanadoo.fr> <1126485412.479800.227880@o13g2000cwo.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1126501877 6955 62.49.19.209 (12 Sep 2005 05:11:17 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Mon, 12 Sep 2005 05:11:17 +0000 (UTC) Cancel-Lock: sha1:Z7C+S6furN5lClwatckEpB4PH9A= User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (darwin) Xref: g2news1.google.com comp.lang.ada:4586 Date: 2005-09-12T06:11:13+01:00 List-Id: "jimmaureenrogers@worldnet.att.net" writes: > James wrote: >> This is a very small program compiled under linux debian with gnat 4 >> based on gcc 4.0 >> The output of the program is >> 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 >> 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 >> which is of course not right... >> If line labelled 1 is removed and replaced by line labelled 2, the >> output is correct. >> The output is also correct if part 1 is replaced by part 2. >> Any advice or place where I could send a bug report? >> >> with Text_Io; >> use Text_Io; >> with Interfaces; >> use Interfaces; >> >> >> procedure Toto is >> type Intboard is new Unsigned_64; >> for Intboard'Size use 64; >> type Bit is new Integer range 0..1; >> for Bit'Size use 1; > > You seem to think that Bit is an unsigned type. > It is not. It is a derived type from Integer, which is a > signed type. > > If you want an unsigned integer with a range of 0..1 > you should declare: > > type Bit is mod 2; > > Ada unsigned integer types are defined using modular types. > > I am willing to bet the answer will improve if you use a > modular type. It certainly _changes_ (well, I'm pretty sure it did, but I've been playing around for a little while, so maybe I got confused ...). As it does if you add A_I := 0; before James's 'part 1' (prints all 0's), or if you change optimisation level (-O2 gave 0 1 1 1 0 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 1 0 1 1 0 0 1 1 0 1 1 1 0 0 1 1 0 1 1 1 0 ). This is 4.0.0 on powerpc-apple-darwin7.9.0. I think if it was a size problem, there would have been a compilation error with type Bitboard is array (0 .. 63) of Bit; pragma Pack (Bitboard); for Bitboard'Size use 64; or come to that with for Bit'Size use 1; (remember that Natural'Size is 31). Looks like a bug. To report bugs, go to http://gcc.gnu.org, there are links at the bottom on the left. As a general rule, using overlays like this is not something to be done casually, Ada.Unchecked_Conversion is usually better. That said, I've not seen overlays give this sort of problem before.