comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: Semantics of Inline vs non-Inline
Date: Fri, 15 Oct 2004 10:05:32 +0200
Date: 2004-10-15T10:05:32+02:00	[thread overview]
Message-ID: <6545303.EbTl0XcSZp@linux1.krischik.com> (raw)
In-Reply-To: 416F1EA4.5080700@acm.org

Arthur Schwarz wrote:

> Martin Krischik wrote:
> 
>> skidmarks wrote:
> 
>> 
>> 1st: only aliased data is guaranteed to have an 'Address. Even non inline
>> functions may use a register for certain data.

>    Going back to the 'Address issue, it is my (unsubstantiated) belief
>    that if the semantics are to be the same for inline and non-inline
>    code, then it should be the compilers responsibility to ensure
>    that argument passage is guaranteed to be correct. Otherwise any
>    argument passed to a subprogram becomes suspect as being able to
>    generate a fault at runtime.

Yes. Depending on compiler/cpu the non inlined version might not work
either. Unless you use some representation clause the compiler has a lot of
freedom to perform the parameter passing. You need to ensure the data does
indeed have an address.

i.E.:

ᅵᅵᅵfunctionᅵPush(ᅵDatumᅵ:ᅵaccess Datum_Typeᅵ)ᅵreturnᅵList.Cell_Ptrᅵis
ᅵᅵᅵᅵᅵᅵLM_Datumᅵ:ᅵList.Datum_Type;
ᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵᅵforᅵLM_Datum'AddressᅵuseᅵDatum.all'Address;
ᅵᅵᅵbeginᅵ--ᅵPush
ᅵᅵᅵᅵᅵreturnᅵList.Push(LM_Datum);
ᅵᅵᅵendᅵPush;
ᅵᅵᅵpragmaᅵinline(ᅵPushᅵ);

By passing an access you force the compiler to make sure an address is
available. 

>    My objection is that the non-inlined code, with all it's conceptual
>    and design flaws, works as expected. The inline code fails at run-
>    time without a diagnostic message at compile time. My expectation
>    was that the results of inline execution and non-inline execution
>    should have been the same.

Yes, they should both fail. Again: only aliased data is guaranteed to have
an 'Address. There are rules in Ada for Pass by Reference and Free to
Choose. Free to Choose is the largest group.

Pass on Stack is only needed for "Pragma Export" and "Pragma Import". So an
PowerPC or 68xxxx CPU which have lots of registers even the non inlined
version may use register and pass by copy for parameter passing.

>    And so I am confused. The question is still whether Ada requires
>    that the result of execution of the inline and non-inline code to
>    be the same, and if not the same, what variances are permitted.

The non inlined version only works because you where luck. However, there is
just one thing where you should go back to your verndor and insist on a bug
to be fixed: PROGRAM_ERROR should have been raised. And most compilers
issue a warning when the code for PROGRAM_ERROR is generated. 

With Regards

Martin
-- 
mailto://krischik@users.sourceforge.net
http://www.ada.krischik.com




  reply	other threads:[~2004-10-15  8:05 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <35f054ea.0410140733.5f250e6f@posting.google.com>
2004-10-14 16:14 ` Semantics of Inline vs non-Inline Wojtek Narczynski
2004-10-14 20:05   ` Arthur Schwarz
2004-10-15 10:24     ` Wojtek Narczynski
2004-10-15 16:32       ` Arthur Schwarz
2004-10-14 17:58 ` Martin Krischik
2004-10-15  0:49   ` Arthur Schwarz
2004-10-15  8:05     ` Martin Krischik [this message]
2004-10-15 16:39       ` Arthur Schwarz
2004-10-15 16:40       ` Arthur Schwarz
2004-10-15 16:40       ` Arthur Schwarz
2004-10-15 16:45       ` skidmarks
2004-10-15  3:40 ` Steve
2004-10-15  5:50 ` Simon Wright
2004-10-15 16:57   ` skidmarks
2004-10-18 17:01 ` skidmarks
2004-10-15  6:18 Christoph Karl Walter Grein
2004-10-15 11:02 ` Wojtek Narczynski
  -- strict thread matches above, loose matches on Subject: below --
2004-10-18  6:29 Christoph Karl Walter Grein
2004-10-20 15:07 ` Wojtek Narczynski
2004-10-21  5:07 Christoph Karl Walter Grein
2004-10-21 10:24 ` Wojtek Narczynski
2004-10-21 11:21 Christoph Karl Walter Grein
2004-10-21 20:57 ` Wojtek Narczynski
2004-10-22  0:46 ` skidmarks
2004-10-22  5:50   ` Simon Wright
2004-10-22 12:57     ` Wojtek Narczynski
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox