comp.lang.ada
 help / color / mirror / Atom feed
* Intermediate expressions and modular types
@ 1997-10-18  0:00 Martin Kristensson
  1997-10-18  0:00 ` Robert A Duff
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kristensson @ 1997-10-18  0:00 UTC (permalink / raw)



-- 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?

Surely the correct behavior must be stated in the RM, but where?

Thanks for your help,
/Martin.




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Intermediate expressions and modular types
  1997-10-18  0:00 Intermediate expressions and modular types Martin Kristensson
@ 1997-10-18  0:00 ` Robert A Duff
  0 siblings, 0 replies; 2+ messages in thread
From: Robert A Duff @ 1997-10-18  0:00 UTC (permalink / raw)



In article <344898BA.7361@dtek.chalmers.se>,
Martin Kristensson  <d95krima@dtek.chalmers.se> 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




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-10-18  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-18  0:00 Intermediate expressions and modular types Martin Kristensson
1997-10-18  0:00 ` Robert A Duff

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