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,6249925d5f58c31 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Intermediate expressions and modular types Date: 1997/10/18 Message-ID: #1/1 X-Deja-AN: 282229678 References: <344898BA.7361@dtek.chalmers.se> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-10-18T00:00:00+00:00 List-Id: In article <344898BA.7361@dtek.chalmers.se>, Martin Kristensson wrote: >-- Ada95 >type Modular is mod 2**32; >procedure Test(ModA, ModB : in Modular) is > X : Integer; >begin > X := Integer(ModA - ModB); >end Test; > >The intermediate expression (ModA - ModB) is calculated modulo 2**32 by >compiler A, but not by compiler B. >Which is right? Compiler A. >Surely the correct behavior must be stated in the RM, but where? Not sure what to quote here. 3.5.4(19) defines the normal "wrap-around" semantics of the "-" operator on modular types -- in fact it talks about all operators. So perhaps the issue is that Compiler A thinks it's a Modular "-", whereas Compiler B thinks it's an Integer "-". The former is correct, which follows from all the visibility and overloading rules and so forth, but 4.6(7) says that the "-" chosen comes from the types of the operands. Most likely, it's just a plain old code generation bug, so there's no RM exegesis necessary to convince the maintainers of Compiler B that they have a bug. Why "Compiler A" and "Compiler B"? Why can't names be named here? Is someone afraid of being sued for saying so-and-so compiler has a bug?! Of course, to indicate a compiler bug, one has to produce a complete program, which prints out a wrong answer. - Bob