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,45a9122ddf5fcf5 X-Google-Attributes: gid103376,public From: mazzanti@iei.pi.cnr.it (Franco Mazzanti) Subject: Re: Rules for Representation of Subtypes Date: 1996/10/03 Message-ID: #1/1 X-Deja-AN: 186957238 organization: IEI-CNR newsgroups: comp.lang.ada Date: 1996-10-03T00:00:00+00:00 List-Id: Robert A Duff wrote: > >generic > > type Source(<>) is limited private; > > type Target is (<>); > >function Checked_Scalar_Conversion (S:Source) return Target; > > > > > >with Unchecked_Conversion; > >function Checked_Scalar_Conversion (S : Source) return Target is > > type My_Rec is record > > Scalar : Target; > > That's illegal, since Target has unknown discrims. But other than that, > this approach will work. > > But, you don't really need to go to all that trouble. If you just make > sure your integer types match the hardware (like -2**31..2**31-1 or > whatever), then unchecked conv of integers will tend to work just fine. > ... > ... > > - Bob illegal? isn't Target required to be just a discrete type [RM 12.5.2(2)]? If I am wrong, is this a GNAT bug (since it compiles without problem)? Notice that all this trouble might be needed if I want my program to be as far as possible implementation-independent, or if I want to look for same mechanically verifiable (as far as possible implementation-independent) safe coding guidelines (without going to disallow all unchecked conversions). Franco