* Are there any "bad" Ada constructs?
@ 1996-09-04 0:00 Gordon Dodrill
1996-09-05 0:00 ` Jerome Desquilbet
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Gordon Dodrill @ 1996-09-04 0:00 UTC (permalink / raw)
The C and C++ language have several constructs that are undefined enough
that two conforming compilers are permitted to give different results and
still be correct. One example is,
i = 2;
a[i] = i++;
Executing the second of these two statements, assuming they are properly
declared first, a compiler is permitted to assign the value of 2 to either
a[2] or a[3] and be correct. This construct is stated to be undefined by
the ANSI-C standard, and any compiler can actually do anything it pleases.
I saw one reference that stated there are 150 of these sorts of things in
C and C++.
My question is: Are there any constructs in Ada that are permitted to do
two or more different things and still be correct, in a manner that
is similar to that listed above?
Thanks,
Gordon
// Coronado Enterprises Tutorials - Ada, C, C++, Pascal
// Learn to program in a modern language
// All are available at http://www.swcp.com/~dodrill
// Gordon Dodrill - dodrill@swcp.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Are there any "bad" Ada constructs?
1996-09-04 0:00 Are there any "bad" Ada constructs? Gordon Dodrill
@ 1996-09-05 0:00 ` Jerome Desquilbet
1996-09-05 0:00 ` Peter Amey
1996-09-05 0:00 ` Dennison
2 siblings, 0 replies; 5+ messages in thread
From: Jerome Desquilbet @ 1996-09-05 0:00 UTC (permalink / raw)
To: Gordon Dodrill
Gordon,
You may find useful information in Ada Quality and Style Guides at
http://lglwww.epfl.ch/Ada/Resources/References.html#style
Jerome.
______________________________________________________________________
Jerome Desquilbet jDesquilbet@Rational.COM
' ^
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Are there any "bad" Ada constructs?
1996-09-04 0:00 Are there any "bad" Ada constructs? Gordon Dodrill
1996-09-05 0:00 ` Jerome Desquilbet
@ 1996-09-05 0:00 ` Peter Amey
1996-09-16 0:00 ` George Haddad
1996-09-05 0:00 ` Dennison
2 siblings, 1 reply; 5+ messages in thread
From: Peter Amey @ 1996-09-05 0:00 UTC (permalink / raw)
>
> My question is: Are there any constructs in Ada that are permitted to do
> two or more different things and still be correct, in a manner that
> is similar to that listed above?
>
There are, mostly associated with aliasing, evaluation order and
elaboration order. A simple example is:
procedure Init2(X, Y : out integer)
is
begin
X := 1;
Y := 2;
end Init2;
The call Init2(A, A); can set A to 1 or 2 because the order of parameter
association is undefined (I have two validated compilers which actually
demonstrate this effect).
Ada has a bit of a cop out in that it labels programs whose meaning
varies in this way "erroneous"; however, applying such a label doesn't
make the problems any easier to detect or prevent. Some secure Ada
subsets such as SPARK are completely free of this form of anomalous
behaviour.
Peter
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Are there any "bad" Ada constructs?
1996-09-04 0:00 Are there any "bad" Ada constructs? Gordon Dodrill
1996-09-05 0:00 ` Jerome Desquilbet
1996-09-05 0:00 ` Peter Amey
@ 1996-09-05 0:00 ` Dennison
2 siblings, 0 replies; 5+ messages in thread
From: Dennison @ 1996-09-05 0:00 UTC (permalink / raw)
Gordon Dodrill wrote:
>
> The C and C++ language have several constructs that are undefined enough
> that two conforming compilers are permitted to give different results and
> still be correct. One example is,
> My question is: Are there any constructs in Ada that are permitted to do
> two or more different things and still be correct, in a manner that
> is similar to that listed above?
In Ada 83, anything defined in the LRM to be "erronious" would fall into
this catagory.
--
email - mailto:dennison@iag.net
homepage - http://www.iag.net/~dennison
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1996-09-16 0:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-09-04 0:00 Are there any "bad" Ada constructs? Gordon Dodrill
1996-09-05 0:00 ` Jerome Desquilbet
1996-09-05 0:00 ` Peter Amey
1996-09-16 0:00 ` George Haddad
1996-09-05 0:00 ` Dennison
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox