From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, MSGID_SHORT,REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!seas.gwu.edu!mfeldman From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada Subject: "silly" (?) Ada semantics Message-ID: <1919@sparko.gwu.edu> Date: 2 Jun 90 21:08:13 GMT Reply-To: mfeldman@seas.gwu.edu (Michael Feldman) Organization: The George Washington University, Washington D.C. List-Id: 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 ---------------------------------------------------------------------------