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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:a24:454e:: with SMTP id y75mr1157849ita.37.1548317598986; Thu, 24 Jan 2019 00:13:18 -0800 (PST) X-Received: by 2002:a9d:709a:: with SMTP id l26mr105197otj.1.1548317598897; Thu, 24 Jan 2019 00:13:18 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.166.215.MISMATCH!k10no103726itk.0!news-out.google.com!v71ni151ita.0!nntp.google.com!k10no103723itk.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 24 Jan 2019 00:13:18 -0800 (PST) In-Reply-To: <06c9823b-eaa1-49ea-a8fb-9a5704ac06b3@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2003:c7:83db:8df6:4af:234d:34f1:3409; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf NNTP-Posting-Host: 2003:c7:83db:8df6:4af:234d:34f1:3409 References: <3d782720-227d-4d86-b403-eacbd1b9d0d2@googlegroups.com> <06c9823b-eaa1-49ea-a8fb-9a5704ac06b3@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Problem with Position of the enumeration Type From: AdaMagica Injection-Date: Thu, 24 Jan 2019 08:13:18 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:55357 Date: 2019-01-24T00:13:18-08:00 List-Id: Am Mittwoch, 23. Januar 2019 21:22:09 UTC+1 schrieb Shark8: > What you want is Unchecked_Conversion, to do this well you want to specify the sizes so they match up. Tht's correct, sizes of source and target must be same. > Type Enum_Reps is range 10..14 -- You could hide this in the private section, > with Size => Natural'Size; -- and have renaming-as-a-body for the actual > -- conversion functions. But this is wrong. Enum_Reps'Size (Natural as defined) is very different from E_Test'Size. If you want to know what might happen in this case, see http://www.christ-usch-grein.homepage.t-online.de/AdaMagica/Prokrustes-e.html I was bitten by this when porting Ada code from one architeture and commpiler to a different archit. and comp. > Function Convert is new Unchecked_Conversion( E_Test, Enum_Reps ); > Function Convert is new Unchecked_Conversion( Enum_Reps, E_Test ); > > and then just use Convert.