Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
const2.go33 linesDownload Raw Back to test
1// errorcheck2 3// Copyright 2009 The Go Authors. All rights reserved.4// Use of this source code is governed by a BSD-style5// license that can be found in the LICENSE file.6 7// Verify that large integer constant expressions cause overflow.8// Does not compile.9 10package main11 12const (13	A int = 114	B byte;	// ERROR "type without expr|expected .=.|missing init expr"15)16 17const LargeA = 100000000000000000018const LargeB = LargeA * LargeA * LargeA19const LargeC = LargeB * LargeB * LargeB // GC_ERROR "constant multiplication overflow"20 21const AlsoLargeA = LargeA << 400 << 400 >> 400 >> 400 // GC_ERROR "constant shift overflow"22 23// Issue #42732.24 25const a = 1e+50000000026const b = a * a // ERROR "constant multiplication overflow|not representable"27const c = b * b28 29const MaxInt512 = (1<<256 - 1) * (1<<256 + 1)30const _ = MaxInt512 + 1  // ERROR "constant addition overflow"31const _ = MaxInt512 ^ -1 // ERROR "constant bitwise XOR overflow"32const _ = ^MaxInt512     // ERROR "constant bitwise complement overflow"33 
codekingpro/portable-devtools · Team Ai