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, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Path: utzoo!utgpu!water!watmath!clyde!rds@moss.ATT.COM From: rds@moss.ATT.COM Newsgroups: comp.lang.ada Subject: Operator Overloading Resolution Message-ID: <30740@clyde.ATT.COM> Date: 4 Aug 88 17:59:22 GMT Sender: nuucp@clyde.ATT.COM Reply-To: rds@clyde.ATT.COM (Richard DeSimine) Organization: AT&T Bell Laboratories, Whippany NJ List-Id: 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......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