comp.lang.ada
 help / color / mirror / Atom feed
From: Georg Bauhaus <bauhaus@futureapps.invalid>
Subject: Re: Is this a bug in my code or the compiler?
Date: Sat, 13 Jun 2015 12:04:57 +0200
Date: 2015-06-13T12:04:57+02:00	[thread overview]
Message-ID: <mlgv5n$hqp$1@dont-email.me> (raw)
In-Reply-To: <1g33axhwakrzx.o6t14iz4jruy.dlg@40tude.net>

On 12.06.15 20:00, Dmitry A. Kazakov wrote:
> On Fri, 12 Jun 2015 19:25:00 +0200, G.B. wrote:
>
>> On 12.06.15 18:15, Dmitry A. Kazakov wrote:
>>> Foo (A) and Foo (A) -- Illegal
>>> Foo (A) and then Foo (A) -- Legal
>>
>> C has similar features...
>
> So?
>
>>> P.P.S. It would become even worse with fine-grained parallelism, as Georg
>>> keep on suggesting.
>>
>> Not sure to what this is referring
>
> Parallel evaluation of arguments.

Yes, but where is the difference, exactly, between incorrect due
to order dependence, and incorrect due to sharing issues? If
nothing is lost by forcing an order on evaluation of arguments
on all programs, then I don't know any more why that's not enforced
by languages, and why instead we saw Haskell.

>> So, in Ada 83, when A is of an access type,
>
> That does not change anything because:
>
>>      Foo (A) and Foo (A)  -- Legal
>
> Only if A is a constant access. Illegal otherwise.

Is there chapter and verse in the 83 LRM for this? I found this in 1.6:

"Whenever the reference manual specifies that different parts of a given
  construct are to be executed in some order that is not defined by the language,
  this means that the implementation is allowed to execute these parts
  in any given order, following the rules that result from that given order,
  but not in parallel. Furthermore, the construct is incorrect if execution
  of these parts in a different order would have a different effect.
  Compilers are not required to provide either compilation-time or run-time
  detection of incorrect order dependences."

(No mention of legality here.)

So, is GNAT buggy if it accepts this Ada 83 program (you claim that
it is *easy* to detect aliasing of A and B):

WITH Text_IO;
PROCEDURE Par IS
    TYPE I IS RANGE 1 .. 3;
    TYPE Ptr IS ACCESS I;
    A, B: Ptr;
    V, Legal : Boolean;
    
    FUNCTION Foo (X : Ptr) RETURN Boolean IS SEPARATE;
    
    PACKAGE Boolean_Io IS NEW Text_IO.Enumeration_IO (Boolean);
BEGIN
    A := NEW I'(1);
    
    Boolean_Io.Get (V);

    IF V THEN
       B := A;
    ELSE
       B := NEW I'(3);
    END IF;
    
    Legal := Foo (A) AND Foo (B);  -- legal?

END Par;

>  parallelism is a can of worms.

... if designed without regard to parallel evaluation/execution.
That's a matter of course, isn't it?

  reply	other threads:[~2015-06-13 10:04 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-12 15:56 Is this a bug in my code or the compiler? David Botton
2015-06-12 16:15 ` Dmitry A. Kazakov
2015-06-12 17:25   ` G.B.
2015-06-12 18:00     ` Dmitry A. Kazakov
2015-06-13 10:04       ` Georg Bauhaus [this message]
2015-06-13 10:32         ` Dmitry A. Kazakov
2015-06-15 10:37           ` G.B.
2015-06-15 12:27             ` Dmitry A. Kazakov
2015-06-15 12:31               ` Simon Wright
2015-06-15 13:16                 ` Dmitry A. Kazakov
2015-06-15 14:56                   ` Simon Wright
2015-06-15 15:03                     ` G.B.
2015-06-13 19:42       ` Brad Moore
2015-06-12 17:53   ` David Botton
2015-06-12 18:11     ` Dmitry A. Kazakov
2015-06-12 18:43       ` marciant
2015-06-12 19:37     ` Jeffrey R. Carter
2015-06-12 19:55       ` Simon Wright
2015-06-12 20:40         ` Jeffrey R. Carter
2015-06-12 21:40           ` Simon Wright
2015-06-12 19:39     ` jan.de.kruyf
2015-06-12 22:10       ` David Botton
2015-06-13  0:19         ` Dennis Lee Bieber
2015-06-13 14:21         ` jan.de.kruyf
2015-06-14  3:13     ` Randy Brukardt
2015-06-14  3:21     ` Randy Brukardt
2015-06-12 16:48 ` Jeffrey R. Carter
2015-06-13 13:33 ` Jacob Sparre Andersen
2015-06-13 15:15   ` J-P. Rosen
2015-06-13 16:43     ` Jacob Sparre Andersen
2015-06-13 20:50       ` J-P. Rosen
2015-06-14  3:18   ` Randy Brukardt
2015-06-14  3:10 ` Randy Brukardt
2015-06-14  9:02   ` Jacob Sparre Andersen
2015-06-14 12:48     ` brbarkstrom
2015-06-15 22:06     ` Randy Brukardt
replies disabled

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