comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Ada or C++ acting 'correctly' here?
Date: 1999/02/27
Date: 1999-02-27T00:00:00+00:00	[thread overview]
Message-ID: <m3hfs82by3.fsf@mheaney.ni.net> (raw)
In-Reply-To: 7b8c7u$sj1@drn.newsguy.com

bill@mooner writes:

> compare these 2 little programs, do same thing, one in C++
> and one in Ada. The C++ program compiles Ok, but result is
> negative, the Ada program refused to compile:

...

> test_multi.adb:6:18: value not in range of type "Standard.Integer"
> test_multi.adb:6:18: static expression raises "Constraint_Error"

...

> Now. Which would you consider the correct language behaviour?
> (same machine, Pentium pro, Linux.


You may be comparing apples and oranges.

I you want to duplicate the C++, then use a modular type.  Instantiate
Text_IO.Modular_IO on Interfaces.Unsigned_32, and then compare results.
(Print out the values in hex.)

The other thing you could try is to create a non-static value in the Ada
program, and then be sure to compare with overflow checks off (the
default in gnat).  This would be closer to the C++ program.

The fact that the Ada code refuses to compile, you should regard as a
Good Thing, since it doesn't make any sense to try to print out an
unrepresentable value.














  reply	other threads:[~1999-02-27  0:00 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-27  0:00 Ada or C++ acting 'correctly' here? bill
1999-02-27  0:00 ` Matthew Heaney [this message]
1999-02-27  0:00 ` Gautier.DeMontmollin
1999-02-27  0:00 ` Claudius Proculus
1999-02-27  0:00   ` Biju Thomas
1999-02-28  0:00     ` robert_dewar
1999-02-28  0:00       ` Florian Weimer
1999-03-01  0:00         ` dewar
1999-02-27  0:00 ` Florian Weimer
     [not found]   ` <36e8e201.48455851@netnews.worldnet.att.net>
1999-03-18  0:00     ` bglbv
1999-02-27  0:00 ` Steve Doiel
1999-02-28  0:00 ` robert_dewar
1999-02-28  0:00 ` William McKenzie
1999-03-01  0:00   ` Hubert B. Keller
1999-03-01  0:00   ` fraser
1999-03-02  0:00 ` Willliam V
1999-03-02  0:00   ` Pascal Obry
1999-03-02  0:00   ` Gautier.DeMontmollin
1999-03-02  0:00     ` kvisko
1999-03-02  0:00   ` robert_dewar
1999-03-02  0:00   ` SpamSpamSpam
replies disabled

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