From: Robert Griesemer Date: Wed, 17 Jan 2018 05:30:46 +0000 (-0800) Subject: spec: mention that special case for integer division is due to overflow X-Git-Tag: go1.10rc1~33 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=18d527b3f09521a21e4068917f9b4513fcfcc2ef;p=gostls13.git spec: mention that special case for integer division is due to overflow Fixes #23443. Change-Id: If60c39b582ee5308e9fa902f93c1b6ae7890346c Reviewed-on: https://go-review.googlesource.com/87975 Reviewed-by: Ian Lance Taylor Reviewed-by: Rob Pike --- diff --git a/doc/go_spec.html b/doc/go_spec.html index f009ec0054..1ada626bf0 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -3558,9 +3558,10 @@ with x / y truncated towards zero

-As an exception to this rule, if the dividend x is the most -negative value for the int type of x, the quotient -q = x / -1 is equal to x (and r = 0). +The one exception to this rule is that if the dividend x is +the most negative value for the int type of x, the quotient +q = x / -1 is equal to x (and r = 0) +due to two's-complement integer overflow:

@@ -3623,11 +3624,11 @@ discard high bits upon overflow, and programs may rely on "wrap around".
 

For signed integers, the operations +, --, *, and << may legally +-, *, /, and << may legally overflow and the resulting value exists and is deterministically defined by the signed integer representation, the operation, and its operands. -No exception is raised as a result of overflow. A -compiler may not optimize code under the assumption that overflow does +No exception is raised as a result of overflow. +A compiler may not optimize code under the assumption that overflow does not occur. For instance, it may not assume that x < x + 1 is always true.