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-Thread: 103376,b2923d60cb81694b X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!postnews.google.com!c51g2000cwc.googlegroups.com!not-for-mail From: "Adam Beneschan" Newsgroups: comp.lang.ada Subject: Re: Unsigned Integer Restraint Errors Date: 12 Mar 2007 10:23:39 -0700 Organization: http://groups.google.com Message-ID: <1173720219.194301.327140@c51g2000cwc.googlegroups.com> References: <1173712032.183064.264340@8g2000cwh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Trace: posting.google.com 1173720243 27554 127.0.0.1 (12 Mar 2007 17:24:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 12 Mar 2007 17:24:03 +0000 (UTC) In-Reply-To: <1173712032.183064.264340@8g2000cwh.googlegroups.com> User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.7.12) Gecko/20050922 Fedora/1.7.12-1.3.1,gzip(gfe),gzip(gfe) Complaints-To: groups-abuse@google.com Injection-Info: c51g2000cwc.googlegroups.com; posting-host=66.126.103.122; posting-account=cw1zeQwAAABOY2vF_g6V_9cdsyY_wV9w Xref: g2news1.google.com comp.lang.ada:14485 Date: 2007-03-12T10:23:39-07:00 List-Id: On Mar 12, 8:07 am, "frikk" wrote: > LASTLY: > Please note that when I change the range value from 0 .. 5 to 0 .. > 2**64-1, or 0 .. UNSIGNED_LONG_INT'Last, there is no constraint error > raised. This is the same behavior as the first example. I missed this question the first time. The reason for this is probably that special things are needed to do this sort of check. When you declare a subtype in the range 0 .. 5, the code generated by the compiler can do its normal arithmetic operations, and then check to see if the result is less than 0 or greater than 5. But when you declare a subtype in the range 0..2**64-1, the code can't do this, because *all* 64-bit integers are going to appear to be in this range. In order to do the check, either the compiler will need to generate additional special code, or it will need to do something to enable the processor's hardware overflow mechanism. On GNAT and some other compilers, this requires that you use a special flag when compiling. This might be -gnato, but I don't remember offhand, and I'm hoping someone else will tell us what it is so that I don't have to look it up myself. -- Adam