From: mfeldman@seas.gwu.edu (Michael Feldman)
Subject: "silly" (?) Ada semantics
Date: 2 Jun 90 21:08:13 GMT [thread overview]
Message-ID: <1919@sparko.gwu.edu> (raw)
A recent posting suggested trying the following program on my compiler:
procedure MAIN is
A: array(1..2, 1..3) of INTEGER;
begin
A := ((2,2),(3,3,3), (4,4,4,4));
end MAIN;
Well, here are the results, in the order Irvine (HP835), Meridian (Sun-3),
Verdix (Sun-3), TeleSoft (Sun-3). In all 4 cases, the compilers flagged the
offending initialization of the array with warnings indicating that
constraint_error would be raised at execution time. What is the point
about the "silly" semantics: that the compiler should treat it as fatal?
Well, OK, maybe it should. As a teacher of compiler construction, I know
well that the question of what to treat as a fatal error is really a
matter of taste. Let's not turn this into a religious thing, OK?
---------- cut here ------------
1 | procedure MAIN is
2 | A: array(1..2, 1..3) of INTEGER;
3 | begin
4 | A := ((2,2),(3,3,3), (4,4,4,4));
***** > "silly.ada", line 4: Exception Warning: LRM4.3.2.11 Subaggregate array bounds not the same.
***** > "silly.ada", line 4: Exception Warning: LRM4.3.2.11 Subaggregate array bounds not the same.
***** > "silly.ada", line 4: Warning: Incompatible array bounds (1..4 not compatible with 1..3).
5 | end MAIN;
***** > "silly.ada", line 2: Advisory Warning: Variable A never read.
5 lines compiled.
No errors detected.
4 warnings issued.
----------- cut here ----------
Meridian AdaVantage v4.0 Source file: silly.ada Page 1
Sat Jun 2 1990 16:47:46 EDT
1 procedure MAIN is
2 A: array(1..2, 1..3) of INTEGER;
3 begin
4 A := ((2,2),(3,3,3), (4,4,4,4));
+
+++++W subtype check will raise constraint_error [LRM 10.6/3]
+
+
+++++W value out of range will raise constraint_error [LRM 10.6/3]
+
+
+++++W subtype check will raise constraint_error [LRM 10.6/3]
+
+
+++++W value out of range will raise constraint_error [LRM 10.6/3]
+
+
+++++W value out of range will raise constraint_error [LRM 10.6/3]
+
5 end MAIN;
----------- cut here ----------
Verdix Ada Compiler, Copyright 1984, 1985, 1986, 1987, 1988, 1989
Version 5.7 - Sun UNIX
Fri Apr 21 08:49:57 PDT 1989 (d)
File: /usr.MC68020/sparko/1/faculty/mfeldman/verdix/silly.ada
compiled Sat Jun 2 16:51:16 1990
by user mfeldman
floating point processor MC68881
unit: subprogram body main
NO Ada ERRORS UNIT ENTERED
3 statements 5 lines
********************************* silly.ada *********************************
1:procedure MAIN is
2: A: array(1..2, 1..3) of INTEGER;
3: begin
4: A := ((2,2),(3,3,3), (4,4,4,4));
A -------------^
B ----------------^
C -----------------^
D --------------------------------^
A:warning: RM 5.2.1(2): arrays have different sizes: will raise CONSTRAINT_ERROR
B:warning: RM 3.6.1(16) and 5.2.1(2): wrong number of elements
B:warning: bounds check will raise CONSTRAINT_ERROR at runtime
B:warning: bounds check will raise CONSTRAINT_ERROR at runtime
B:warning: RM 3.6.1: bounds check will raise CONSTRAINT_ERROR at runtime
B:warning: RM 3.6.1: bounds check will raise CONSTRAINT_ERROR at runtime
C:warning: RM 3.6.1(16) and 5.2.1(2): wrong number of elements
D:warning: RM 3.6.1(16) and 5.2.1(2): wrong number of elements
5: end MAIN;
----------- cut here ----------
TeleGen2 (tm) Ada Compilation System -- Version 1.4
Copyright 1989 TeleSoft. All rights reserved.
File: /usr.MC68020/sparko/1/faculty/mfeldman/telesoft/silly.ada
Date: 1990-Jun-02 16:54:55
Front-End : silly.ada
Middle-Pass : main (specification)
Code-Generator : main (specification)
Middle-Pass : main (body)
4: A := ((2,2),(3,3,3), (4,4,4,4));
>>> WARNING: Length Check will raise Constraint Error
4: A := ((2,2),(3,3,3), (4,4,4,4));
>>> WARNING: Length Check will raise Constraint Error
4: A := ((2,2),(3,3,3), (4,4,4,4));
>>> WARNING: High Check will raise Constraint_Error
4: A := ((2,2),(3,3,3), (4,4,4,4));
>>> WARNING: Matching Array Length Check will raise Constraint_Error
Code-Generator : main (body)
---------------------------------------------------------------------------
Prof. Michael Feldman
Department of Electrical Engineering and Computer Science
The George Washington University
Washington, DC 20052
+1-202-994-5253
mfeldman@seas.gwu.edu
---------------------------------------------------------------------------
next reply other threads:[~1990-06-02 21:08 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
1990-06-02 21:08 Michael Feldman [this message]
1990-06-05 9:54 ` "silly" (?) Ada semantics ken
1990-06-06 16:09 ` Michael Feldman
1990-06-06 22:27 ` Robert I. Eachus
1990-06-07 14:32 ` Michael Feldman
1990-06-06 18:12 ` Robert I. Eachus
1990-06-07 17:27 ` stt
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox