comp.lang.ada
 help / color / mirror / Atom feed
From: stt@henning.camb.inmet.com (Tucker Taft)
Subject: Re: Which compiler is correct??
Date: 1996/09/12
Date: 1996-09-12T00:00:00+00:00	[thread overview]
Message-ID: <DxLMEu.DF9.0.-s@inmet.camb.inmet.com> (raw)
In-Reply-To: 514uuu$d8i@uuneo.neosoft.com


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




  parent reply	other threads:[~1996-09-12  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-09-10  0:00 Which compiler is correct?? Robert B. Love 
1996-09-10  0:00 ` Robert Dewar
1996-09-11  0:00   ` Robert B. Love 
1996-09-10  0:00 ` Robert Dewar
1996-09-11  0:00 ` Robert A Duff
1996-09-12  0:00   ` Ken Cowan
1996-09-12  0:00   ` Ken Cowan
1996-09-13  0:00   ` Jon S Anthony
1996-09-11  0:00 ` Jon S Anthony
1996-09-12  0:00 ` Tucker Taft [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-06-17  0:00 Which compiler is correct? Tom Moran
1997-06-18  0:00 ` Pascal Obry
1997-06-18  0:00   ` Tom Moran
1997-06-18  0:00 ` Robert A Duff
1997-06-18  0:00   ` John Woodruff
1997-06-19  0:00     ` Robert A Duff
1997-06-20  0:00     ` Jon S Anthony
1997-06-21  0:00       ` Robert A Duff
1997-06-26  0:00         ` Jon S Anthony
1997-06-19  0:00   ` Simon Wright
1997-06-20  0:00     ` Jon S Anthony
1997-06-21  0:00       ` Robert A Duff
1997-06-21  0:00     ` Robert A Duff
1997-06-21  0:00       ` Simon Wright
1997-06-23  0:00       ` Mats.Weber
1997-06-24  0:00         ` Jon S Anthony
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox