modernc.org/gc@v1.0.1-0.20240304020402-f0dba7c97c2b/testdata/errchk/test/const2.go (about) 1 // errorcheck 2 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. 6 7 // Verify that large integer constant expressions cause overflow. 8 // Does not compile. 9 10 package main 11 12 const ( 13 A int = 1 14 B byte; // ERROR "type without expr|expected .=." 15 ) 16 17 const LargeA = 1000000000000000000 18 const LargeB = LargeA * LargeA * LargeA 19 const LargeC = LargeB * LargeB * LargeB // GC_ERROR "constant multiplication overflow" 20 21 const AlsoLargeA = LargeA << 400 << 400 >> 400 >> 400 // GC_ERROR "constant shift overflow"