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,ae233931baf2d312 X-Google-Attributes: gid103376,public From: dewar@cs.nyu.edu (Robert Dewar) Subject: Re: Integer'Size < 32 ? Date: 1996/08/10 Message-ID: #1/1 X-Deja-AN: 173289724 references: <9608081258.AA02749@most> organization: Courant Institute of Mathematical Sciences newsgroups: comp.lang.ada Date: 1996-08-10T00:00:00+00:00 List-Id: Wes asks " .... range -(2**31) .. ((2**31)-1) I once used a compiler for which Integer'Size = 32 and which had an interesting "feature." It recognized that the above would fit in 32 bits, so it compiled for that size. Then at run-time, it would (obeying the precedence rules) try to compute 2**31 and raise constraint_error. (I didn't use the parentheses, but that doesn't change the semantics.) The ugly work-around was .... range -2**31 .. 2**30 + (2**30 - 1); My question is, "Is this a common 'feature'?" (Since so many people have quoted the same example, I presume the answer is 'no')" First of all let's talk Ada 83. In Ada 83: type x is range -(2**31) .. ((2**31)-1); must work (if there is a suitable base type), and cannot raise constraint error. However subtype y is x range -(2**31) .. ((2**31)-1); is allowed to raise constraint error, although not required to, and notably the DEC compiler *did* raise constraint error, although most other compilers did not. This was a well known source of undesirable non-portability, and so in Ada 95, the rules about static expressions were modified to require that all intermediate static expressions be computed without overflow, so the above subtype declaration CANNOT cause constraint error in Ada 95.