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: 109fba,98ad5b2a2cd88a53 X-Google-Attributes: gid109fba,public X-Google-Thread: 103376,98ad5b2a2cd88a53 X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: Ada or C++ acting 'correctly' here? Date: 1999/02/27 Message-ID: #1/1 X-Deja-AN: 449275273 Sender: matt@mheaney.ni.net References: <7b8c7u$sj1@drn.newsguy.com> NNTP-Posting-Date: Sat, 27 Feb 1999 05:46:48 PDT Newsgroups: comp.lang.ada,comp.lang.c++ Date: 1999-02-27T00:00:00+00:00 List-Id: 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.