2012-02-16 21:48:57 -07:00
|
|
|
// errorcheck
|
2009-03-12 20:04:38 -06:00
|
|
|
|
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2012-02-18 19:19:43 -07:00
|
|
|
// Verify that large integer constant expressions cause overflow.
|
|
|
|
// Does not compile.
|
|
|
|
|
2009-03-12 20:04:38 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
const (
|
2010-09-03 18:36:13 -06:00
|
|
|
A int = 1
|
2009-03-16 22:48:07 -06:00
|
|
|
B byte; // ERROR "type without expr|expected .=."
|
2009-03-12 20:04:38 -06:00
|
|
|
)
|
2012-02-10 22:50:56 -07:00
|
|
|
|
|
|
|
const LargeA = 1000000000000000000
|
|
|
|
const LargeB = LargeA * LargeA * LargeA
|
2012-02-15 16:19:42 -07:00
|
|
|
const LargeC = LargeB * LargeB * LargeB // ERROR "constant multiplication overflow"
|
|
|
|
|
|
|
|
const AlsoLargeA = LargeA << 400 << 400 >> 400 >> 400 // ERROR "constant shift overflow"
|