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 10.36.101.12 with SMTP id u12mr15889929itb.30.1520462342483; Wed, 07 Mar 2018 14:39:02 -0800 (PST) X-Received: by 10.157.96.5 with SMTP id h5mr1254825otj.14.1520462342294; Wed, 07 Mar 2018 14:39:02 -0800 (PST) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!border1.nntp.ams1.giganews.com!nntp.giganews.com!peer01.ams1!peer.ams1.xlned.com!news.xlned.com!peer01.am4!peer.am4.highwinds-media.com!peer02.iad!feed-me.highwinds-media.com!news.highwinds-media.com!e10no466271itf.0!news-out.google.com!a25ni972itj.0!nntp.google.com!e10no466268itf.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 7 Mar 2018 14:39:02 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.71.218.250; posting-account=QF6XPQoAAABce2NyPxxDAaKdAkN6RgAf NNTP-Posting-Host: 173.71.218.250 References: <60f20df9-4b33-4f29-829e-2fccb89a650a@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <428eeffb-0054-4693-9ef3-fa218125fb76@googlegroups.com> Subject: Re: expression functions and raise expressions From: Jere Injection-Date: Wed, 07 Mar 2018 22:39:02 +0000 Content-Type: text/plain; charset="UTF-8" X-Received-Bytes: 3837 X-Received-Body-CRC: 3727872078 Xref: reader02.eternal-september.org comp.lang.ada:50885 Date: 2018-03-07T14:39:02-08:00 List-Id: On Monday, March 5, 2018 at 3:21:18 PM UTC-5, Randy Brukardt wrote: > "Jere" wrote in message > >I wanted to double check if I am reading the RM correctly. > > From 6.8 2/4, I see that a function expression can consist entirely > > of an (expression) > > > > Section 4.4 2 says that an expression can be made up of a single > > (relation) > > > > Section 4.4 3/4 further says a relation can be a raise expression. > > > > Given that, I expect that the following declaration/definition is correct: > > > > function Reference > > (Container : aliased in out Container_Type; > > Cursor : Cursor_Type) > > return Reference_Type > > is (raise My_Exception > > with "Reference not supported for Ordered_Sets") > > with Inline; > > > > GNAT GPL 2017 accepts it, but FSF GNAT 7.2 for mingw64 on Win10 > > gives some errors: > > test.ads:328:11: (Ada 2005) cannot copy object of a limited type (RM-2005 > > 6.5(5.5/2)) > > test.ads:328:11: return by reference not permitted in Ada 2005 > > > > NOTE: Reference_Type is untagged limited discriminated null > > record with Implicit_Dereference defined. Also note that a similar > > function that returns an aggregate initialization compiles fine > > on both versions. > > > > I am compiling with Ada2012 mode (-gnat12 option) > > > > I believe this to be a bug in GCC 7.2 for mingw64, but wanted to > > make sure I wasn't misreading the RM. > If "Reference_Type" is a limited type, then this would have been correct at > one point: we forgot to allow raise expressions in limited contexts. (Recall > that returning a limited expression from a function is "built-in-place" and > only allows certain expressions, copying objects [for instance] is not > allowed.) I noticed this when writing some ACATS tests in this area, and it > was fixed with a recent Binding Interpretation (correction). But it won't > formally be adopted until Ada 2020, so an Ada 2012 compiler is ""correct" if > it allows or rejects such a use (as corrections can, but don't have to be, > applied to the existing language). > > For a non-limited type, this should be just fine. But as a raise expression > matches any type (and thus is different than any previous Ada expression), > it might be buggy in some odd case. > > Randy. > Thanks! It was a limited type. I guess for now, I won't use them in expression functions then so I can keep it portable. It was just convenient, but not a show stopper.