3 // Copyright 2009 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
7 // Verify that large integer constant expressions cause overflow.
14 B byte; // ERROR "type without expr|expected .=."
17 const LargeA = 1000000000000000000
18 const LargeB = LargeA * LargeA * LargeA
19 const LargeC = LargeB * LargeB * LargeB // GC_ERROR "constant multiplication overflow"
21 const AlsoLargeA = LargeA << 400 << 400 >> 400 >> 400 // GC_ERROR "constant shift overflow"
25 const a = 1e+500000000
26 const b = a * a // ERROR "constant multiplication overflow"
29 const MaxInt512 = (1<<256 - 1) * (1<<256 + 1)
30 const _ = MaxInt512 + 1 // ERROR "constant addition overflow"
31 const _ = MaxInt512 ^ -1 // ERROR "constant bitwise XOR overflow"
32 const _ = ^MaxInt512 // ERROR "constant bitwise complement overflow"