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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,3a7c118fd2cc64f9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!news2.google.com!postnews.google.com!k22g2000yqh.googlegroups.com!not-for-mail From: AdaMagica Newsgroups: comp.lang.ada Subject: Re: A hole in Ada type safety Date: Thu, 12 May 2011 22:31:17 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <87oc3odtci.fsf@mid.deneb.enyo.de> <715a5498-095c-4e61-8a09-8510c19b2553@s16g2000prf.googlegroups.com> NNTP-Posting-Host: 80.156.44.178 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1305264677 2346 127.0.0.1 (13 May 2011 05:31:17 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 13 May 2011 05:31:17 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k22g2000yqh.googlegroups.com; posting-host=80.156.44.178; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:2.0.1) Gecko/20100101 Firefox/4.0.1,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:20218 Date: 2011-05-12T22:31:17-07:00 List-Id: On 13 Mai, 02:47, a...@att.net wrote: > -- > -- =A0May be this program will help explain the problem. > -- (erased a lot of irrelevant stuff) > =A0 -- ------------------ -- > =A0 -- =A0Ada05_Conversion =A0-- > =A0 -- ------------------ -- > =A0 generic > =A0 =A0 type Source (<>) is limited private ; > =A0 =A0 type Target (<>) is limited private ; > =A0 =A0 function Ada05_Conversion ( S : Source ) return Target ; > > =A0 function Ada05_Conversion ( S : Source ) return Target is > > =A0 =A0 =A0 pragma Suppress ( All_Checks ) ; > > =A0 =A0 begin > =A0 =A0 =A0 -- Compiling Error messages: > =A0 =A0 =A0 -- =A0 (Ada 2005) cannot copy object of a limited type > =A0 =A0 =A0 -- =A0 =A0 =A0 =A0 =A0 =A0 =A0(RM-2005 6.5(5.5/2)) > =A0 =A0 =A0 -- =A0 consider switching to return of access type > =A0 =A0 =A0 -- > =A0 =A0 =A0 -- Additional References for reasoning: > =A0 =A0 =A0 -- =A0 RM 7.5 Limited Types ( 1/2, 1.a, 1.b/2 ) > =A0 =A0 =A0 -- > =A0 =A0 =A0 return Target ( S ) ; What you are writing here is a normal type conversion with certain rules (RM 4.6), not an unchecked type conversion (RM 13.9). For a type conversion to be legal, the types involved have to be convertible. Source and Target are not convertible, so this whole thing is illegal for several reasons. > =A0 =A0 end Ada05_Conversion ; RTFM