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,4b89102f705d4611,start X-Google-Attributes: gid103376,public From: "Marc A. Criley" Subject: The Incredible Shrinking Type Date: 2000/11/06 Message-ID: <3A0703F5.9333AE56@earthlink.net>#1/1 X-Deja-AN: 690410846 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 973542072 63.178.180.16 (Mon, 06 Nov 2000 12:21:12 PST) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Mon, 06 Nov 2000 12:21:12 PST Newsgroups: comp.lang.ada Date: 2000-11-06T00:00:00+00:00 List-Id: The following program exhibits what is, to me, somewhat unexpected behavior. I define an overly long type by applying a size attibute of 72 bits. The Linux GNAT compiler (3.13) allocates 128 bits for objects of this type, which is a reasonable thing for it to do. However, when passing an instance of this type as a parameter to a procedure and extracting its 'Size, the result is 64. What happened to the rest of the bits? Granted, they were unused, but still... Where is this behavior addressed by the language (if it is), or is it a freedom granted to compiler implementor's? -------------------------------------------------------------- with System; with Text_IO; use Text_IO; procedure Chk_Size is type Modest_Type is range 0..99; for Modest_Type'Size use 72; MT : Modest_Type; procedure Dump_Size(Param : Modest_Type) is begin Put_Line("Param'Size is" & Natural'Image(Param'Size)); end Dump_Size; begin Put_Line("Modest_Type size: " & Natural'Image(Modest_Type'Size)); Put_Line("MT obj size: " & Natural'Image(MT'Size)); Dump_Size(MT); end Chk_Size; -------------------------------------------------------------- Compiling this does generate the warning: chk_size.adb:7:29: warning: 64 bits of "Modest_Type" unused Running it produces: Modest_Type size: 72 MT obj size: 128 Param'Size is 64 Marc A. Criley