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!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Is this a bug in my code or the compiler? Date: Sat, 13 Jun 2015 22:10:34 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <4f4cd4b1-0a6d-441b-a4f7-98add70e4e1e@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1434251435 24130 24.196.82.226 (14 Jun 2015 03:10:35 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Sun, 14 Jun 2015 03:10:35 +0000 (UTC) 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.6157 Xref: news.eternal-september.org comp.lang.ada:26313 Date: 2015-06-13T22:10:34-05:00 List-Id: "David Botton" wrote in message news:4f4cd4b1-0a6d-441b-a4f7-98add70e4e1e@googlegroups.com... > Given: > > function Token_Start (Source : in out Awesome.Source.Source_Type'Class) > return Character; > function Token_End (Source : in out Awesome.Source.Source_Type'Class) > return String; > > The following works: > > function Get_Token_Text (Source : in out > Awesome.Source.Source_Type'Class) > return String > is > N : Character := Token_Start (Source); > begin > return N & Token_End (Source); > end Get_Token_Text; > > The following does not work: > > function Get_Token_Text (Source : in out > Awesome.Source.Source_Type'Class) > return String > is > begin > return Token_Start (Source) & Token_End (Source); > end Get_Token_Text; > > Token_End is never called and only the value of Token_Start. I would have expected this second expression to be illegal, because it seems to violate 6.4.1(6.18-19/3). That rule was introduced in Ada 2012 along with "in out" function parameters to avoid "obvious" dependence on order of evaluation. The rule is: If a construct C has two or more direct constituents that are names or expressions whose evaluation may occur in an arbitrary order, at least one of which contains a function call with an in out or out parameter, then the construct is legal only if: For each name N that is passed as a parameter of mode in out or out to some inner function call C2 (not including the construct C itself), there is no other name anywhere within a direct constituent of the construct C other than the one containing C2, that is known to refer to the same object. (Here C is "&", N is Source, and C2 is Token_Start; the rule says that Source can't appear outside of the call of Token_Start, and it does. I'd suggest filing a bug report.) Randy.