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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!io.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: expression functions and raise expressions Date: Mon, 5 Mar 2018 14:21:15 -0600 Organization: JSA Research & Innovation Message-ID: References: <60f20df9-4b33-4f29-829e-2fccb89a650a@googlegroups.com> Injection-Date: Mon, 5 Mar 2018 20:21:16 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="31332"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader02.eternal-september.org comp.lang.ada:50825 Date: 2018-03-05T14:21:15-06:00 List-Id: 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. "Jere" wrote in message news:60f20df9-4b33-4f29-829e-2fccb89a650a@googlegroups.com... >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.