comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Compiler Bug
Date: Wed, 5 Dec 2007 21:30:08 -0600
Date: 2007-12-05T21:30:08-06:00	[thread overview]
Message-ID: <fja0id$8t5$1@jacob-sparre.dk> (raw)
In-Reply-To: 9984a3f8-1e45-44c0-96d6-4bd9462c57d5@d27g2000prf.googlegroups.com

"Adam Beneschan" <adam@irvine.com> wrote in message
news:9984a3f8-1e45-44c0-96d6-4bd9462c57d5@d27g2000prf.googlegroups.com...
...
> 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.

I think that you are right in this case. If there were exception handlers in
the code, then some optimizations wouldn't be allowed.

                    Randy.





  parent reply	other threads:[~2007-12-06  3:30 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: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
2007-12-06  3:30             ` Randy Brukardt
2007-12-06  3:30             ` Randy Brukardt [this message]
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