aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/testdata/const0.src
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/compile/internal/types2/testdata/const0.src')
-rw-r--r--src/cmd/compile/internal/types2/testdata/const0.src17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/testdata/const0.src b/src/cmd/compile/internal/types2/testdata/const0.src
index 9e0de93d54..5608b1549b 100644
--- a/src/cmd/compile/internal/types2/testdata/const0.src
+++ b/src/cmd/compile/internal/types2/testdata/const0.src
@@ -350,9 +350,14 @@ const _ = unsafe.Sizeof(func() {
})
// untyped constants must not get arbitrarily large
-const (
- huge = 1<<1000
- // TODO(gri) here the errors should be at the last operator not the last operand
- _ = huge * huge * huge // ERROR constant multiplication overflow
- _ = huge << 1000 << 1000 // ERROR constant shift overflow
-)
+const prec = 512 // internal maximum precision for integers
+const maxInt = (1<<(prec/2) - 1) * (1<<(prec/2) + 1) // == 1<<prec - 1
+
+const _ = maxInt + /* ERROR constant addition overflow */ 1
+const _ = -maxInt - /* ERROR constant subtraction overflow */ 1
+const _ = maxInt ^ /* ERROR constant bitwise XOR overflow */ -1
+const _ = maxInt * /* ERROR constant multiplication overflow */ 2
+const _ = maxInt << /* ERROR constant shift overflow */ 2
+const _ = 1 << /* ERROR constant shift overflow */ prec
+
+const _ = ^ /* ERROR constant bitwise complement overflow */ maxInt