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,XPRIO autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,148ece082805bf8f,start X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-12-13 07:53:20 PST Path: supernews.google.com!sn-xit-02!sn-post-01!supernews.com!corp.supernews.com!not-for-mail From: "Jeff Creem" Newsgroups: comp.lang.ada Subject: GNAT bug with respect to an Implementation Advise Date: Wed, 13 Dec 2000 10:53:36 -0500 Organization: Posted via Supernews, http://www.supernews.com Message-ID: X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 X-Complaints-To: newsabuse@supernews.com Xref: supernews.google.com comp.lang.ada:3068 Date: 2000-12-13T10:53:36-05:00 List-Id: 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)