comp.lang.ada
 help / color / mirror / Atom feed
* GNAT bug with respect to an Implementation Advise
@ 2000-12-13 15:53 Jeff Creem
  2000-12-13 19:56 ` Florian Weimer
  2000-12-14  1:40 ` Robert Dewar
  0 siblings, 2 replies; 7+ messages in thread
From: Jeff Creem @ 2000-12-13 15:53 UTC (permalink / 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)






^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2000-12-15 22:00 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-12-13 15:53 GNAT bug with respect to an Implementation Advise Jeff Creem
2000-12-13 19:56 ` 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

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