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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,233f0e04e488a4a2 X-Google-Attributes: gid103376,public From: Markus Kuhn Subject: Re: Size of 0..255 is not 8 bits? Date: 1998/05/14 Message-ID: <355AEA1D.6C292667@cl.cam.ac.uk>#1/1 X-Deja-AN: 353187718 Content-Transfer-Encoding: 7bit References: <355A436E.11F76529@cl.cam.ac.uk> Content-Type: text/plain; charset=us-ascii Organization: Cambridge University, Computer Laboratory Mime-Version: 1.0 Newsgroups: comp.lang.ada Date: 1998-05-14T00:00:00+00:00 List-Id: Matthew Heaney wrote: > Better is to throw a size clause on your object: > > type Value is range 0..255; > V : Value; > for V'Size use 8; This did not change anything, V is still a 16-bit integer. I get no difference whether the 'Size clause is for the type, the object, both or none at all. Only type Value is mod 2**8; gave me really an 8-bit unsigned integer variable. > Throw a size clause on your object V, and see what that does. Nothing. I see, why 0..255 requires an at least 9-bit signed type, but I am somewhat disappointed that neither the type'Size nor the object'Size clause gives me a compiler warning that this is not an 8-bit type. So all this IMHO means that either gnat-3.10p contains an error here or that John Barnes wrote nonsense in "Programming in Ada95", 1996, p. 526, where he writes "Thus type Byte is range 0..255; for Byte'Size use 8; indicates that objects of the type Byte should occupy only 8 bits." The weirdest effect is that if I read the file content "ABCDEFGH...", I get only every second byte (65 67 69 ...) with Value'Read, and not as I would have expected a sequence of 16-bit values (65+66*2**8 67+68*2**8 ...) or constraint errors. Any guru insight? Other question: If the rest of a stream is too short for a T'Read to succeed, what is supposed to happen? Constraint error? The ARM doesn't say much on this subject. Markus -- Markus G. Kuhn, Security Group, Computer Lab, Cambridge University, UK email: mkuhn at acm.org, home page: