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=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,dfadb64ce9f4daa5 X-Google-Attributes: gid103376,public From: stt@henning.camb.inmet.com (Tucker Taft) Subject: Re: Which compiler is correct?? Date: 1996/09/12 Message-ID: #1/1 X-Deja-AN: 180064714 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: henning.camb.inmet.com references: <514uuu$d8i@uuneo.neosoft.com> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-09-12T00:00:00+00:00 List-Id: Robert B. Love (rlove@neosoft.com) wrote: : I've got a situation where I put the same piece of code thru two : compilers on the same hardware and one will compile it, the other : gives errors. The code is listed below and is taken from Richard : Riehle's article in JOOP on "Managing Runtime Faults". GNAT compiles : it fine. Aacademic ObjectAda fails to compile it. : I can see maybe 4 choices: 1) GNAT is wrong, 2) ObjectAda is : wrong, 3) the code is wrong, 4) I need to set some compile : switches on one compiler or the other. (1) and (3). : On a PC with GNAT 304a touted as being compiled for Windows and : GNAT 301 on a NeXT/M68040 I get no errors. : With Academic ObjectAda v7.0.171 I get 3 occurrences of the same error : along with line and column numbers. : : LRM:6.4.15(5) If the mode is IN OUT or OUT, the actual : shall be a name that denotes a variable. Aren't you going to tell us what lines and columns it identified??? : I need a language lawyer to tell me what is actually wrong. Or the LRM ;-). : Note I made 2 change to Riehle's article, commented with "my change" : with ada.exceptions; use ada.exceptions; : with text_io,ada.integer_text_io;use text_io; : procedure exception_demo is : error_list: array(1..3) of exception_occurrence; : d1,d2,d3: integer; : function square(data:integer) return integer is : begin : return data*data; : exception : when error_in_square_function: : constraint_error => ada.exceptions.save_occurrence : (error_in_square_function,error_list(1)); This looks like your problem. Procedure Save_Occurrence has two parameters, the first is mode OUT, and the second is mode IN (RM95 11.4.1(6)). "Error_In_Square_Function" is a constant (RM95 11.2(9)), so you can't pass it to an OUT parameter. I suspect you meant to save the result in error_list(1), so you will need to reverse the parameters, or even better, use named notation (which is a good idea any time there are two consecutive parameters of the same type, and the operation isn't commutative). Presumably the GNAT bug is that it doesn't consider a "choice parameter" like "error_in_square_function" to be a constant, so it doesn't catch your mistake. The same problem occurs in your other 2 calls on Save_Occurrence. I presume the line and column numbers given in the error message pointed to the "error_in_square_function" operand. .. : Bob Love, rlove@neosoft.com (local) MIME & NeXT Mail OK : rlove@raptor.rmnug.org (permanent) PGP key available -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA