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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: Paul Rubin Newsgroups: comp.lang.ada Subject: Re: Should exceeding the range of Integer wrap around a la C? Date: Mon, 21 May 2018 12:11:43 -0700 Organization: A noiseless patient Spider Message-ID: <87vabgn7rk.fsf@nightsong.com> References: <7ba47ec1-28e7-43e1-83a0-2a4d2cf0fd92@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: h2725194.stratoserver.net; posting-host="c6481957bb4c16cd24a15f0721180494"; logging-data="8476"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18bD8Rv8CpYLmlWYp+NrElX" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) Cancel-Lock: sha1:eltaS4ZoEXcG+giabIZHm0SHAVo= sha1:UFSmtMgdx+QD3ewte3Fqfb3y/2s= Xref: reader02.eternal-september.org comp.lang.ada:52552 Date: 2018-05-21T12:11:43-07:00 List-Id: > Should exceeding the range of Integer wrap around a la C? It should raise a constraint error unless you turn off the check. I don't know if there is a specified result mandated if you have an overflow with the check turned off. In C, unsigned integer overflow is undefined behaviour, like a subscript overflow. Wraparound is one common result because of how machine arithmetic works, but it is not guaranteed. The program could instead crash, or delete your files, or anything else. See here: http://blog.llvm.org/2011/05/what-every-c-programmer-should-know.html