comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeff Creem" <jeff@thecreems.com>
Subject: GNAT bug with respect to an Implementation Advise
Date: Wed, 13 Dec 2000 10:53:36 -0500
Date: 2000-12-13T10:53:36-05:00	[thread overview]
Message-ID: <t3f6rg54jlkfee@corp.supernews.com> (raw)

The LRM has an implementation advice that says:

13.13.2(17): Stream Oriented Attributes

If a stream element is the same size as a storage element, then the normal
in-memory representation should be used by Read and Write for scalar
objects. Otherwise, Read and Write should use the smallest number of stream
elements needed to represent all values in the base range of the scalar
type.

To which the GNAT RM says

Followed.

It appears to me that unsigned integers created by means other than modular
types to not follow this rule.

Given the following program :


with Ada.Streams.Stream_Io;
with Text_Io;
procedure Ia_Problem is
type My_Type is mod 2**16;
for My_Type'Size use 16;
type My_Int is range - 2**15 ..
(2**15) - 1;
for My_Int'Size use 16;

type My_Uint is range 0 .. 65535;
for My_Uint'Size use 16;

A : My_Type := 5;
B : My_Int := 10;
C : My_Uint := 100;
File : Ada.Streams.Stream_Io.File_Type;
begin
Ada.Streams.Stream_Io.Create(
File => File,
Name => "show.bin");
My_Type'Write(Ada.Streams.Stream_Io.Stream(File),A); -- writes 16 bits
My_Int'Write(Ada.Streams.Stream_Io.Stream(File),B); -- writes 16 bits
My_Uint'Write(Ada.Streams.Stream_Io.Stream(File),C); -- writes 32 bits?
Text_Io.Put_Line(Integer'Image(C'Size));
Ada.Streams.Stream_Io.Close(File);
end Ia_Problem;



The 'write on my_uint writes 32 bits not 16 bits. I realize that the 'write
and 'size is an area where non-language
lawyers get into trouble all the time but it sure seems to me as if GNAT is
not following the IA.

What do others think?

(Note : CC'd to report@gnat.com)






             reply	other threads:[~2000-12-13 15:53 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-12-13 15:53 Jeff Creem [this message]
2000-12-13 19:56 ` GNAT bug with respect to an Implementation Advise Florian Weimer
2000-12-14  0:49   ` Randy Brukardt
2000-12-14  1:40 ` Robert Dewar
2000-12-14  2:40   ` Jeff Creem
2000-12-14 22:47     ` Randy Brukardt
2000-12-15 22:00       ` Randy Brukardt
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox