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,98ad5b2a2cd88a53 X-Google-Attributes: gid103376,public X-Google-Thread: 109fba,98ad5b2a2cd88a53 X-Google-Attributes: gid109fba,public From: Florian Weimer Subject: Re: Ada or C++ acting 'correctly' here? Date: 1999/02/27 Message-ID: #1/1 X-Deja-AN: 449353831 References: <7b8c7u$sj1@drn.newsguy.com> Mail-Copies-To: never Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@cygnus.stuttgart.netsurf.de X-Trace: deneb.cygnus.stuttgart.netsurf.de 920128551 1364 192.168.0.1 (27 Feb 1999 15:15:51 GMT) Organization: Penguin on board User-Agent: Gnus/5.070079 (Pterodactyl Gnus v0.79) XEmacs/20.4 (Emerald) Mime-Version: 1.0 NNTP-Posting-Date: 27 Feb 1999 15:15:51 GMT Newsgroups: comp.lang.ada,comp.lang.c++ Date: 1999-02-27T15:15:51+00:00 List-Id: bill@mooner writes: > ---------------------------- > #include > int main() > { > cout<<(500000000*7); > return 0; > } > ----------------------------- Quotation from ISO/IEC 14882:1998(E), Chapter 5 (Expressions): | 5 If during the evaluation of an expression, the result is not | mathematically defined or not in the range of representable values | for its type, the behavior is undefined, unless such an expression is | a constant expression (5.19), in which case the program is ill-formed. The standard doesn't mention that no diagnonstic is required, so conforming implementations have to refuse to compile this program. > ---------------------------- > with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; > procedure Test_Multi is > begin > Put( 500000000*7 ); > end Test_Multi; > ----------------------------- Quotation from ISO/IEC 8652:1995(E), Section 4.9 (Static Expressions and Static Subtypes): | 33 A static expression is evaluated at compile time except when it is | part of the right operand of a static short-circuit control form whose | value is determined by its left operand. This evaluation is performed | exactly, without performing Overflow_Checks. For a static expression | that is evaluated: | | 34 The expression is illegal if its evaluation fails a | language-defined check other than Overflow_Check. Again, conforming compilers must refuse to compile this program. (BTW: It's pretty pointless to compare languages this way, isn't it?)