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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a1ce307c10055549 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-23 20:16:01 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!canoe.uoregon.edu!arclight.uoregon.edu!wn13feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail From: "David Thompson" Newsgroups: comp.lang.ada References: <3DF1615C.7AAAC86E@adaworks.com> <3DF1B042.6603DDDE@easystreet.com> <3DF2A483.EC512CDF@adaworks.com> <8db3d6c8.0212091445.12594821@posting.google.com> <3DF628C4.7090607@cogeco.ca> <3DF6653D.3030603@cogeco.ca> <8db3d6c8.0212101850.51506572@posting.google.com> <1039618741.173427@master.nyc.kbcfp.com> <8db3d6c8.0212111251.1ecca62e@posting.google.com> <3DF8D46C.1040404@cogeco.ca> Subject: Re: IBM Acquires Rational Ada X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.00.2615.200 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 Message-ID: <5cRN9.76731$hK4.6274098@bgtnsc05-news.ops.worldnet.att.net> Date: Tue, 24 Dec 2002 04:16:01 GMT NNTP-Posting-Host: 12.89.146.11 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1040703361 12.89.146.11 (Tue, 24 Dec 2002 04:16:01 GMT) NNTP-Posting-Date: Tue, 24 Dec 2002 04:16:01 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:32270 Date: 2002-12-24T04:16:01+00:00 List-Id: Warren W. Gay VE3WWG wrote : > Here's another one ;-) > > main(){ > short i = -32768; > short j; > > j = -i; > } > > The results are implementation specific (although > that may have changed with C99 -- I stopped > caring after I got into Ada ;-) I have seen > j=0 in my travels, but don't count on it. > Well, in C99 your example as written is illegal, because "implicit int" function return type, or variable type, is gone; also, since you neither return'ed from main() or exit()'ed in C89 the program exit status was undefined but in C99 it is now zero = successful as a special feature^Wkludge. Not to mention that your entire body is all dead code that any decent optimizer can completely eliminate. But those are irrelevant to your point. The minimum ranges of integer types are unchanged, except for the addition of new long long types (signed and unsigned) of at least 64 bits; signed short, and for that matter int, still need not handle +/-32768, although two's-complement implementations, the overwhelming majority, IME always do support -32768 (but not +32768 in 16 bits). Overflow in any signed integer computation was and is Undefined Behavior, which means anything at all is permitted, including but not limited to any value produced or any signal. And that initializer is really an expression: -(unary negate) 32768(positive int or long literal). Even though it may well (and should) be evaluated at compile time, its defined semantics are as for runtime. But the initializer can't overflow because if 32768 is representable in int then -32768 is also, and if not it is evaluated as and must be representable in long. For the initializer value either way, and the computation of -i as signed int (due to the integer promotions) if it does not overflow, the narrowing by assignment (or cast, or at least scalar initialization) of signed integer types is still implementation-defined but is now allowed to "raise ... an I-D signal" instead of producing an I-D result (value). I-D does mean that the implementation must *document* what it does, FWTW. And I've heard of no implementation that raises a signal here; I'm not sure why the committee added this new option. The most recent Rationale draft I've looked at says nothing on this point. -- - David.Thompson 1 now at worldnet.att.net