comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Compiler Bug
Date: Wed, 5 Dec 2007 08:07:54 -0800 (PST)
Date: 2007-12-05T08:07:54-08:00	[thread overview]
Message-ID: <9984a3f8-1e45-44c0-96d6-4bd9462c57d5@d27g2000prf.googlegroups.com> (raw)
In-Reply-To: 877ijtzd6q.fsf@willow.rfc1149.net

On Dec 5, 1:46 am, Samuel Tardieu <s...@rfc1149.net> wrote:
> >>>>> "Adam" == Adam Beneschan <a...@irvine.com> writes:
>
> Adam> That's not true in reverse, by the way... there are legitimate
> Adam> cases when adding an Inline pragma could make a Constraint_Error
> Adam> go away, if an optimizer determines that some of the inlined
> Adam> code can be eliminated for a particular call.
>
> Can you produce such an example? I am curious about it.

I think this is such an example.  It's possible that I'm technically
wrong about what the language requires, though; if so, I'm hoping one
of the other language experts will jump in.  Some of the language
rules about optimization have, I think, always been seen as a bit
fuzzy.


subtype Int10 is Integer range 1..10;

procedure P1 (X : in Int10; Y, Z : out Int10) is
begin
   Y := X + 1;
   Z := X + 5;
end P1;

procedure P2 is
   A1, A2, A3 : Int10;
begin
   ... code whose effect puts the value 6 in A1
   P1 (A1, A2, A3);
   ... code that uses A2 but does nothing with A3
end P2;


Without any inlining, a Constraint_Error will surely be raised when P1
assigns to Z.  If P1 is inlined, however, the compiler could change
the call to P1 to code that, in effect, performs "A2 := A1 + 1; A3 :=
A1 + 5;"; then it could notice that since A3 is a local variable and
is used in the remainder of P2, the assignment "A3 := A1 + 5" is
pointless and can be eliminated---and thus the Constraint_Error would
not be raised.  I believe the Implementation Permissions of 11.6 allow
this result.

                              -- Adam






  reply	other threads:[~2007-12-05 16:07 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-04 21:58 Compiler Bug REH
2007-12-04 22:25 ` Lucretia
2007-12-04 22:32   ` REH
2007-12-04 22:45     ` Randy Brukardt
2007-12-04 22:49       ` REH
2007-12-04 22:54       ` Adam Beneschan
2007-12-05  9:46         ` Samuel Tardieu
2007-12-05 16:07           ` Adam Beneschan [this message]
2007-12-06  3:30             ` Randy Brukardt
2007-12-06  3:30             ` Randy Brukardt
2007-12-04 22:45     ` Randy Brukardt
2007-12-06  6:51     ` Keith Thompson
2007-12-06 16:48       ` REH
  -- strict thread matches above, loose matches on Subject: below --
2008-04-01 11:52 Compiler bug Maciej Sobczak
2008-04-01 13:00 ` Ludovic Brenta
2008-04-01 20:43   ` Maciej Sobczak
2008-04-02 11:39 ` Alex R. Mosteo
2008-04-02 17:44 ` Per Sandberg
replies disabled

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