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,438f2856ab36a026 X-Google-Attributes: gid103376,public From: matthew_heaney@acm.org (Matthew Heaney) Subject: Re: 83/95 issue, bad code or compiler bug Date: 1998/11/20 Message-ID: #1/1 X-Deja-AN: 413721122 Content-transfer-encoding: 8bit References: Content-Type: text/plain; charset=ISO-8859-1 Mime-Version: 1.0 NNTP-Posting-Date: Thu, 19 Nov 1998 18:25:36 PDT Newsgroups: comp.lang.ada Date: 1998-11-20T00:00:00+00:00 List-Id: In article , jeffrey.m.creem@lmco.com (Jeff Creem) wrote: >type My_Integer_Type is range -2**31 .. 2**31-1; >for My_Integer_Type'size use 32; Please use the types in package Interfaces; either Interfaces.Integer_32 or Interfaces.Unsigned_32. >subtype My_Subtype is My_Integer_Type range 0 .. 255; > > >type My_Record is > record > My_Field : My_Subtype; > Other_Field : My_Integer_Type; > end record; > >for My_Record use > record > My_Field at 0 range 0 .. 31; > Other_Field at 4 range 0 .. 31; > end record; > >for My_Record'size use 2 * 32; > This is bad style. For low-level I/O --here, meaning anything that appears as the component of a record with a rep clause-- all scalar types should have no constraints. In your example, My_Field should be of type My_Interger_Type (Interfaces.Integer_32), not My_Subtype. >Is this due to the Ada 83 code being written in a poor totally unportable way, >or is this permitted and expected in Ada 95 or is this a compiler bug (GNAT >does not exhibit this "bad" behaviour on my code but it certainly could >be that the code as written will have implementation defined results). Don't mix rep clauses and types-with-constraints.