Commit cc7c31ba authored by Russ Cox's avatar Russ Cox

64-bit integer math bugs

R=r
DELTA=46  (46 added, 0 deleted, 0 changed)
OCL=29569
CL=29614
parent 3b37b028
// $G $D/$F.go && $L $F.$A || echo BUG: bug155
// 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.
package main
const big uint64 = 1<<63
func f(a uint64) uint64 {
return a << big
}
func main() {
f(1)
}
/*
main·f: doasm: notfound from=75 to=13 (82) SHLQ $-9223372036854775808,BX
main·f: doasm: notfound from=75 to=13 (82) SHLQ $-9223372036854775808,BX
main·f: doasm: notfound from=75 to=13 (82) SHLQ $-9223372036854775808,BX
*/
// $G $D/$F.go || echo BUG: bug156
// 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.
package main
func f(a int64) int64 {
const b int64 = 0;
n := a &^ b;
return n;
}
func main() {
f(1)
}
/*
bug156.go:7: constant 18446744073709551615 overflows int64
*/
...@@ -104,6 +104,16 @@ BUG should compile ...@@ -104,6 +104,16 @@ BUG should compile
5 7 5 7
BUG: should crash BUG: should crash
=========== bugs/bug155.go
main·f: doasm: notfound from=75 to=13 (82) SHLQ $-9223372036854775808,BX
main·f: doasm: notfound from=75 to=13 (82) SHLQ $-9223372036854775808,BX
main·f: doasm: notfound from=75 to=13 (82) SHLQ $-9223372036854775808,BX
BUG: bug155
=========== bugs/bug156.go
bugs/bug156.go:7: constant 18446744073709551615 overflows int64
BUG: bug156
=========== fixedbugs/bug016.go =========== fixedbugs/bug016.go
fixedbugs/bug016.go:7: constant -3 overflows uint fixedbugs/bug016.go:7: constant -3 overflows uint
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment