* Conformance problem in VAX Ada?
@ 1994-12-10 8:54 Dave Papay M/S 7G32 x2791
1994-12-12 16:10 ` Norman H. Cohen
1994-12-13 9:05 ` Andreas Schulz RIT14
0 siblings, 2 replies; 4+ messages in thread
From: Dave Papay M/S 7G32 x2791 @ 1994-12-10 8:54 UTC (permalink / raw)
While writing some code, I accidentally put different default expressions for
a parameter in the declaration and body of a procedure. Here's what it looked
like, except that procedure Error did some real work ;-) :
with Text_IO;
procedure Test is
procedure Error (I : in Integer := Integer'First);
procedure Error (I : in Integer := Integer'Last) is
begin
Text_IO.Put_Line (Integer'Image (I));
end Error;
begin
Error;
end Test;
I compiled it using VAX Ada v2.3-3 under VAX/VMS v5.5-2. The compiler didn't
complain, and I didn't discover the error until I started seeing the effects
of using Integer'Last, rather than Integer'First (which is what I really
wanted). I read over the conformance rules for subprograms, and (as far as I
can determine) I don't think these two specifications conform. The compiler
thinks they do. Is this a compiler problem, or am I missing something in the
conformace rules?
| |
David Papay | o |
papay@acm.org (preferred) | ^/--- | insert your favorite
dpapay@aol.com (alternate) | /> | disclaimer here
| |
| fleche! |
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Conformance problem in VAX Ada?
1994-12-10 8:54 Conformance problem in VAX Ada? Dave Papay M/S 7G32 x2791
@ 1994-12-12 16:10 ` Norman H. Cohen
1994-12-16 13:49 ` Robert Dewar
1994-12-13 9:05 ` Andreas Schulz RIT14
1 sibling, 1 reply; 4+ messages in thread
From: Norman H. Cohen @ 1994-12-12 16:10 UTC (permalink / raw)
In article <00988B51.1523CFA0.69@gtewd.mtv.gtegsc.com>, Dave Papay
M/S 7G32 x2791 <papayd@GTEWD.MTV.GTEGSC.COM> writes:
|> While writing some code, I accidentally put different default expressions for
|> a parameter in the declaration and body of a procedure. Here's what it looked
|> like, except that procedure Error did some real work ;-) :
|>
|> with Text_IO;
|> procedure Test is
|>
|> procedure Error (I : in Integer := Integer'First);
|>
|> procedure Error (I : in Integer := Integer'Last) is
|> begin
|> Text_IO.Put_Line (Integer'Image (I));
|> end Error;
|>
|> begin
|> Error;
|> end Test;
|>
|> I compiled it using VAX Ada v2.3-3 under VAX/VMS v5.5-2. The compiler didn't
|> complain
...
|> Is this a compiler problem, or am I missing something in the
|> conformace rules?
Definitely a compiler problem. Funny thing is, I tried it on a compiler
with a quite different lineage and got the same result. When I changed
the default value in the Error declaration from Integer'First to 0,
however, the compiler caught the mismatch. When I changed it to
Natural'Size, the mismatch was not caught. The compiler's strategy seems
to be, "If you've seen one attribute, you've seen them all."
--
Norman H. Cohen ncohen@watson.ibm.com
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Conformance problem in VAX Ada?
1994-12-10 8:54 Conformance problem in VAX Ada? Dave Papay M/S 7G32 x2791
1994-12-12 16:10 ` Norman H. Cohen
@ 1994-12-13 9:05 ` Andreas Schulz RIT14
1 sibling, 0 replies; 4+ messages in thread
From: Andreas Schulz RIT14 @ 1994-12-13 9:05 UTC (permalink / raw)
In article <00988B51.1523CFA0.69@gtewd.mtv.gtegsc.com>, Dave Papay M/S 7G32 x2791 <papayd@GTEWD.MTV.GTEGSC.COM> writes:
|> I compiled it using VAX Ada v2.3-3 under VAX/VMS v5.5-2. The compiler didn't
|> complain, and I didn't discover the error until I started seeing the effects
|> of using Integer'Last, rather than Integer'First (which is what I really
|> wanted). I read over the conformance rules for subprograms, and (as far as I
|> can determine) I don't think these two specifications conform. The compiler
|> thinks they do. Is this a compiler problem, or am I missing something in the
|> conformace rules?
Well, SunAda thinks they don't conform :
Sun Ada Compiler, Copyright 1984, 1992
Sun-4 SunOS Release 4.0 and 4.1, Version 1.1
Mon Jan 27 13:31:12 PST 1992, Sun Ada 1.1(f)
File: /.../conform.a
compiled Tue Dec 13 09:55:55 1994
unit: subprogram test
2 SEMANTIC ERRORS UNIT UNCHANGED
3 statements 14 lines
********************************* conform.a *********************************
6: procedure Error (I : in Integer := Integer'Last) is
A -------------------^
A:error: RM 6.3.1: subprogram does not conform with specification from:
A:error: error, line 4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Conformance problem in VAX Ada?
1994-12-12 16:10 ` Norman H. Cohen
@ 1994-12-16 13:49 ` Robert Dewar
0 siblings, 0 replies; 4+ messages in thread
From: Robert Dewar @ 1994-12-16 13:49 UTC (permalink / raw)
I certainly agree that this is a compiler problem (failure to diagnose
different default expressions as conformance problem). Here is the GNAT
output:
1. with Text_IO;
2. procedure Test is
3.
4. procedure Error (I : in Integer := Integer'First);
5.
6. procedure Error (I : in Integer := Integer'Last) is
|
>>> not fully conformant with declaration at line 4
>>> default expression for "I" does not match
7. begin
8. Text_IO.Put_Line (Integer'Image (I));
9. end Error;
10.
11. begin
12. Error;
13. end Test;
THe checking of default expressions is tricky, because they don't have
to be identical (for instance X.A can match A, and things get worse in
9X where "+(a,b) can match a+b. On the other hand 3 does not match 1+2,
so if your compiler folds 1+2 to 3 (which you can expect given that 1+2
is static), it had better make sure this does not happen at a point that
will result in false conformance.
Still this particular case seems pretty straightforward, and would suggest
that the compiler(s) involved are taking some shortcuts on conformance
analysis.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~1994-12-16 13:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1994-12-10 8:54 Conformance problem in VAX Ada? Dave Papay M/S 7G32 x2791
1994-12-12 16:10 ` Norman H. Cohen
1994-12-16 13:49 ` Robert Dewar
1994-12-13 9:05 ` Andreas Schulz RIT14
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox