comp.lang.ada
 help / color / mirror / Atom feed
From: rds@moss.ATT.COM
Subject: Operator Overloading Resolution
Date: 4 Aug 88 17:59:22 GMT	[thread overview]
Message-ID: <30740@clyde.ATT.COM> (raw)

The following code segment was compiled using Telesoft 3.15.
According to LRM 6.6(3) "A call to an overloaded subprogram is
ambiguous (and therefore illegal) if...<the parameters>...are
not sufficient to determine exactly one (overloaded) subprogram
specification."

LRM 4.6(15) also states that a conversion can be applied
"if and only if the innermost complete context (see 8.7)
determines a unique (numeric) target type for the implicit
conversion." 


 WORD	: constant := 16;
 
 type INT_SCALAR is range -(2**15) .. (2**15)-1;
 for INT_SCALAR'size use WORD;
  
 left	: INTEGER range -127..128;
 result	: BOOLEAN;
 
 function "-"( right  : in INT_SCALAR) return INT_SCALAR is
     begin
 	return INT_SCALAR(-INTEGER( right ));
     end;
 
 begin
    result := left < -15;
                   -
>>>    Incompatible operand types or operator not visible <4.5 8.3 8.7>

--------------------------------------------------------------------
The expression -15 is evaluated to be of type INT_SCALAR.

Shouldn't this be an ERROR?

DECAda compiles this code without warning, implying the expression -15
is an INTEGER type.

My impression is NEITHER compiler follows the LRM.
Any comments on what is correct, or what other compilers do?

Richard DeSimine        (201) 386-2059
AT&T Bell Laboratories, Whippany, New Jersey 07054

             reply	other threads:[~1988-08-04 17:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-08-04 17:59 rds [this message]
1988-08-08 14:20 ` Operator Overloading Resolution wayne
1988-08-09 13:58 ` Matti J{rvinen
1988-08-10 13:05   ` rds
replies disabled

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