diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug304.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug304.go new file mode 100644 index 0000000000000000000000000000000000000000..4073073eec646a0fadce6709612f565fbdf8215a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug304.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2010 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. + +// Caused a gccgo crash on compilation. +// bug304.go: In function ‘p.f’: +// bug304.go:15:2: internal compiler error: in copy_tree_r, at tree-inline.c:4114 + +package p +type S struct { + v interface{} +} +func g(e interface{}) { } +func f(s S) { + g(s.v.(*int)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug305.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug305.go new file mode 100644 index 0000000000000000000000000000000000000000..0c34b1a9e71aa53c8f6cf27a939e5d778bbf7c96 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug305.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2010 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. + +// Use //line to set the line number of the next line to 20. +//line fixedbugs/bug305.go:20 + +package p + +// Introduce an error which should be reported on line 24. +var a int = "bogus" + +// Line 15 of file. +// 16 +// 17 +// 18 +// 19 +// 20 +// 21 +// 22 +// 23 +// ERROR "cannot|incompatible" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug306.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug306.go new file mode 100644 index 0000000000000000000000000000000000000000..e8967c25ddcf6f0ffaa8a126eda29d5a65d0b890 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug306.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2010 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. + +ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug307.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug307.go new file mode 100644 index 0000000000000000000000000000000000000000..64451252971b15b19db82fb1b48fbf8610ae703c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug307.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2010 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. + +// Valid program, gccgo reported an error. +// bug307.go:14:6: error: complex arguments must have identical types + +package main + +func main() { + var f float64 + _ = complex(1/f, 0) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug308.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug308.go new file mode 100644 index 0000000000000000000000000000000000000000..a23903c49bccfe83457e4c31569907ba4d405a89 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug308.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2010 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. + +// issue 1136 + +package main + +import "fmt" + +func log1(f string, argv ...interface{}) { + fmt.Printf("log: %s\n", fmt.Sprintf(f, argv...)) +} + +func main() { + log1("%d", 42) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug309.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug309.go new file mode 100644 index 0000000000000000000000000000000000000000..d707aa3c934968f8e78cad4f7ac9cec4814cc926 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug309.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2010 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. + +// issue 1016 + +package bug309 + +func foo(t interface{}, c chan int) { + switch v := t.(type) { + case int: + select { + case <-c: + // bug was: internal compiler error: var without type, init: v + } + default: + _ = v + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug311.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug311.go new file mode 100644 index 0000000000000000000000000000000000000000..f5cab44c7e2c93bf0b1b35b38c0d576ab2c22baf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug311.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2010 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 main() { + m := make(map[string][1000]byte) + m["hi"] = [1000]byte{1} + + v := m["hi"] + + for k, vv := range m { + if k != "hi" || string(v[:]) != string(vv[:]) { + panic("bad iter") + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug312.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug312.go new file mode 100644 index 0000000000000000000000000000000000000000..af423e5b293f8849008dd1661273f74de2804f69 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug312.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2010 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. + +// issue 1172 + +package main + +func main() { + var i interface{} + c := make(chan int, 1) + c <- 1 + select { + case i = <-c: // error on this line + } + if i != 1 { + println("bad i", i) + panic("BUG") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug313.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug313.go new file mode 100644 index 0000000000000000000000000000000000000000..f7e023848b6702a1b2e1a15880b4f46ebd559168 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug313.go @@ -0,0 +1,19 @@ +// errorcheckdir + +// Copyright 2010 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. + +// Issue 1284 + +package bug313 + +/* +6g bug313.dir/[ab].go + +Before: +bug313.dir/b.go:7: internal compiler error: fault + +Now: +bug313.dir/a.go:10: undefined: fmt.DoesNotExist +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug314.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug314.go new file mode 100644 index 0000000000000000000000000000000000000000..6e26d14e1f5447be1f3b81c94e965b32db7ea1e2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug314.go @@ -0,0 +1,31 @@ +// run + +// Copyright 2010 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. + +// Used to call wrong methods; issue 1290. + +package main + +type S struct { +} +func (S) a() int{ + return 0 +} +func (S) b() int{ + return 1 +} + +func main() { + var i interface { + b() int + a() int + } = S{} + if i.a() != 0 { + panic("wrong method called") + } + if i.b() != 1 { + panic("wrong method called") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug315.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug315.go new file mode 100644 index 0000000000000000000000000000000000000000..7b8a9e5701296acda09d6ee1ab13be6a62628acb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug315.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2010 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. + +// Issue 1368. + +package main + +func main() { + a := complex(2, 2) + a /= 2 +} + +/* +bug315.go:13: internal compiler error: optoas: no entry DIV-complex +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug316.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug316.go new file mode 100644 index 0000000000000000000000000000000000000000..e1374122d4673ec6f3d9a84149b62cb6faf78c80 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug316.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2010 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. + +// Issue 1369. + +package main + +const ( + c = complex(1, 2) + r = real(c) // was: const initializer must be constant + i = imag(c) // was: const initializer must be constant +) + +func main() {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug317.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug317.go new file mode 100644 index 0000000000000000000000000000000000000000..4cd9ec28130a3f814b7c83ae073e8cc9ac1d08f2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug317.go @@ -0,0 +1,16 @@ +// run + +// Copyright 2011 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 main() { + x := []uint{0} + x[0] &^= f() +} + +func f() uint { + return 1<<31 // doesn't panic with 1<<31 - 1 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug318.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug318.go new file mode 100644 index 0000000000000000000000000000000000000000..93de2d847108a9c49d3879cd15301044df07909c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug318.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 1411. + +package main + +const ui uint = 0 +const i int = ui // ERROR "type" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug319.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug319.go new file mode 100644 index 0000000000000000000000000000000000000000..b93106d4bdb0a64b306d397e3a2c2d62b2d6d3d2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug319.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2011 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 + +import "unsafe" + +func main() { + var x int + + a := uint64(uintptr(unsafe.Pointer(&x))) + b := uint32(uintptr(unsafe.Pointer(&x))) + c := uint16(uintptr(unsafe.Pointer(&x))) + d := int64(uintptr(unsafe.Pointer(&x))) + e := int32(uintptr(unsafe.Pointer(&x))) + f := int16(uintptr(unsafe.Pointer(&x))) + + _, _, _, _, _, _ = a, b, c, d, e, f +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug320.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug320.go new file mode 100644 index 0000000000000000000000000000000000000000..0406b965616d289beab55dd9ebef4b486ae3ad3c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug320.go @@ -0,0 +1,45 @@ +// run + +// Copyright 2011 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 main() { + c := make(chan int, 1) + dummy := make(chan int) + v := 0x12345678 + for i := 0; i < 10; i++ { + // 6g had a bug that caused select to pass &t to + // selectrecv before allocating the memory for t, + // which caused non-deterministic crashes. + // This test looks for the bug by checking that the + // value received actually ends up in t. + // If the allocation happens after storing through + // whatever garbage &t holds, the later reference + // to t in the case body will use the new pointer and + // not see the received value. + v += 0x1020304 + c <- v + select { + case t := <-c: + go func() { + f(t) + }() + escape(&t) + if t != v { + println(i, v, t) + panic("wrong values") + } + case dummy <- 1: + } + } +} + +func escape(*int) { +} + +func f(int) { +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug321.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug321.go new file mode 100644 index 0000000000000000000000000000000000000000..19970af34c215f179d9e99fbe8019f09141327bf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug321.go @@ -0,0 +1,30 @@ +// run + +// Copyright 2011 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. + +// Troublesome floating point constants. Issue 1463. + +package main + +import "fmt" + +func check(test string, got, want float64) bool { + if got != want { + fmt.Println(test, "got", got, "want", want) + return false + } + return true +} + +func main() { + good := true + // http://www.exploringbinary.com/java-hangs-when-converting-2-2250738585072012e-308/ + good = good && check("2.2250738585072012e-308", 2.2250738585072012e-308, 2.2250738585072014e-308) + // http://www.exploringbinary.com/php-hangs-on-numeric-value-2-2250738585072011e-308/ + good = good && check("2.2250738585072011e-308", 2.2250738585072011e-308, 2.225073858507201e-308) + if !good { + panic("fail") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug322.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug322.go new file mode 100644 index 0000000000000000000000000000000000000000..21efbb55935a3306dbadd006e6d1acd02586a1f0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug322.go @@ -0,0 +1,8 @@ +// rundir + +// Copyright 2011 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. + +// Test case for issue 1402. +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug323.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug323.go new file mode 100644 index 0000000000000000000000000000000000000000..3cb8eaab43fb68318998b78e0c20ec36b83652eb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug323.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2011 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 + +type T struct{} +type P *T + +func (t *T) Meth() {} +func (t T) Meth2() {} + +func main() { + t := &T{} + p := P(t) + p.Meth() // ERROR "undefined" + p.Meth2() // ERROR "undefined" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug324.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug324.go new file mode 100644 index 0000000000000000000000000000000000000000..36b8b56d1235d56719d964c399e3d3cfede37114 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug324.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2011 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. + +// Test case for issue 1550: a type cannot implement an interface +// from another package with a private method, and type assertions +// should fail. +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug325.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug325.go new file mode 100644 index 0000000000000000000000000000000000000000..74d7bbb92383b6b602ca7fb3988239a6b902f1f1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug325.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2011 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 + +import "unsafe" + +func main() { + var x unsafe.Pointer + println(*x) // ERROR "invalid indirect.*unsafe.Pointer|cannot indirect" + var _ = (unsafe.Pointer)(nil).foo // ERROR "foo" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug326.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug326.go new file mode 100644 index 0000000000000000000000000000000000000000..74e06f39d78707388830da49486dfe54f1fca84f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug326.go @@ -0,0 +1,39 @@ +// errorcheck + +// Copyright 2011 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 p + +func f() (_ int, err error) { + return +} + +func g() (x int, _ error) { + return +} + +func h() (_ int, _ error) { + return +} + +func i() (int, error) { + return // ERROR "not enough return values|not enough arguments to return" +} + +func f1() (_ int, err error) { + return 1, nil +} + +func g1() (x int, _ error) { + return 1, nil +} + +func h1() (_ int, _ error) { + return 1, nil +} + +func ii() (int, error) { + return 1, nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug327.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug327.go new file mode 100644 index 0000000000000000000000000000000000000000..ecb5d22684227527f8b0ffc348fc6f51c5264290 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug327.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2011 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. + +// Conversion between identical interfaces. +// Issue 1647. + +// The compiler used to not realize this was a no-op, +// so it generated a call to the non-existent function runtime.convE2E. + +package main + +type ( + a interface{} + b interface{} +) + +func main() { + x := a(1) + z := b(x) + _ = z +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug328.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug328.go new file mode 100644 index 0000000000000000000000000000000000000000..57043f30af72dc35d58eb81962fec29d41415ad7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug328.go @@ -0,0 +1,14 @@ +// run + +// Copyright 2011 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 + +import "unsafe" + +func main() { + var p unsafe.Pointer + println(p) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug328.out b/platform/dbops/binaries/go/go/test/fixedbugs/bug328.out new file mode 100644 index 0000000000000000000000000000000000000000..9982566dc094533dcc25d9e38ad7d9f0b4c603d4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug328.out @@ -0,0 +1 @@ +0x0 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug329.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug329.go new file mode 100644 index 0000000000000000000000000000000000000000..37c93d0f6e634e626a53a3d0d1dac6c60b8e919c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug329.go @@ -0,0 +1,46 @@ +// run + +// Copyright 2011 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 + +type Value struct { + X interface{} + Y int +} + +type Struct struct { + X complex128 +} + +const magic = 1 + 2i + +func (Value) Complex(x complex128) { + if x != magic { + println(x) + panic("bad complex magic") + } +} + +func f(x *byte, y, z int) complex128 { + return magic +} + +func (Value) Struct(x Struct) { + if x.X != magic { + println(x.X) + panic("bad struct magic") + } +} + +func f1(x *byte, y, z int) Struct { + return Struct{magic} +} + +func main() { + var v Value + v.Struct(f1(nil, 0, 0)) // ok + v.Complex(f(nil, 0, 0)) // used to fail +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug330.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug330.go new file mode 100644 index 0000000000000000000000000000000000000000..2f33feb4b6afb49ea92844c994823b1c1fa77185 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug330.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2011 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 main() { + x := "" + x = +"hello" // ERROR "invalid operation.*string|expected numeric" + x = +x // ERROR "invalid operation.*string|expected numeric" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug331.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug331.go new file mode 100644 index 0000000000000000000000000000000000000000..9eb57cd3edb0bcc3756491fdc7d5de4523277ce0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug331.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2011 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 + +import "io" + +func f() (_ string, x float64, err error) { + return +} + +func g() (_ string, x float64, err error) { + return "hello", 3.14, io.EOF +} + +var _ func() (string, float64, error) = f +var _ func() (string, float64, error) = g + +func main() { + x, y, z := g() + if x != "hello" || y != 3.14 || z != io.EOF { + println("wrong", x, len(x), y, z) + } +} + +/* +issue 1712 + +bug331.go:12: cannot use "hello" (type string) as type float64 in assignment +bug331.go:12: cannot use 0 (type float64) as type os.Error in assignment: + float64 does not implement os.Error (missing String method) +bug331.go:12: error in shape across RETURN +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug332.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug332.go new file mode 100644 index 0000000000000000000000000000000000000000..159c8b4e68b89c9b3317ce8b0a5fe05f86eaa5c2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug332.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2011 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 + +// type T int + +func main() {} + +// issue 1474 + +// important: no newline on end of next line. +// 6g used to print instead of bug332.go:111 +func (t *T) F() {} // ERROR "undefined.*T" \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug333.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug333.go new file mode 100644 index 0000000000000000000000000000000000000000..149843a3b04904e1c290ab51c00ae9f6ee89f7e7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug333.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2011 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. + +// Issue 1709 + +package main + +func main() { + type Ts string + var ts Ts + _ = []byte(ts) +} + +/* +bug333.go:14: cannot use ts (type Ts) as type string in function argument +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug334.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug334.go new file mode 100644 index 0000000000000000000000000000000000000000..9558c06ca4681dfcd1870b14dcec8d11020b3bda --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug334.go @@ -0,0 +1,31 @@ +// compile + +// Copyright 2011 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. + +// Issue 1716 + +package main + +type ( + cplx64 complex64 + cplx128 complex128 +) + +func (c cplx64) Foo() {} +func (c cplx128) Foo() {} + +func main() { + var c64 cplx128 + var c128 cplx64 + c64.Foo() + c128.Foo() +} + +/* +bug334.go:16: invalid receiver type cplx64 +bug334.go:17: invalid receiver type cplx128 +bug334.go:22: c64.Foo undefined (type cplx128 has no field or method Foo) +bug334.go:23: c128.Foo undefined (type cplx64 has no field or method Foo) +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug335.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug335.go new file mode 100644 index 0000000000000000000000000000000000000000..fda9eb8f0a70bbf7167f1d30d1d424e5110b4c83 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug335.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2011 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. + +// Issue 1705. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug336.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug336.go new file mode 100644 index 0000000000000000000000000000000000000000..fbcd3a51514566bf9479c715de69ccf3e40628db --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug336.go @@ -0,0 +1,86 @@ +// run + +// Copyright 2011 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 + +type T1 struct { + Next *T2 +} + +type T2 T1 + +type T3 struct { + Next *T4 +} + +type T4 T5 +type T5 T6 +type T6 T7 +type T7 T8 +type T8 T9 +type T9 T3 + +type T10 struct { + x struct { + y ***struct { + z *struct { + Next *T11 + } + } + } +} + +type T11 T10 + +type T12 struct { + F1 *T15 + F2 *T13 + F3 *T16 +} + +type T13 T14 +type T14 T15 +type T15 T16 +type T16 T17 +type T17 T12 + +// issue 1672 +type T18 *[10]T19 +type T19 T18 + +func main() { + _ = &T1{&T2{}} + _ = &T2{&T2{}} + _ = &T3{&T4{}} + _ = &T4{&T4{}} + _ = &T5{&T4{}} + _ = &T6{&T4{}} + _ = &T7{&T4{}} + _ = &T8{&T4{}} + _ = &T9{&T4{}} + _ = &T12{&T15{}, &T13{}, &T16{}} + + var ( + tn struct{ Next *T11 } + tz struct{ z *struct{ Next *T11 } } + tpz *struct{ z *struct{ Next *T11 } } + tppz **struct{ z *struct{ Next *T11 } } + tpppz ***struct{ z *struct{ Next *T11 } } + ty struct { + y ***struct{ z *struct{ Next *T11 } } + } + ) + tn.Next = &T11{} + tz.z = &tn + tpz = &tz + tppz = &tpz + tpppz = &tppz + ty.y = tpppz + _ = &T10{ty} + + t19s := &[10]T19{} + _ = T18(t19s) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug337.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug337.go new file mode 100644 index 0000000000000000000000000000000000000000..1a0616f70adf5f8cc8086765ef28a11b1b7a08b9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug337.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 1722. + +// Check that the error messages says +// bug337.go:16: len("foo") not used +// and not +// bug337.go:16: 3 not used + +package main + +func main() { + len("foo") // ERROR "len|value computed is not used" +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug338.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug338.go new file mode 100644 index 0000000000000000000000000000000000000000..a4537a4232952382ac834e1d9ab9e2f9c6c5c648 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug338.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2011 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. + +// Issue 1787. + +package main + +import "unsafe" + +const x = unsafe.Sizeof([8]byte{}) + +func main() { + var b [x]int + _ = b +} + +/* +bug338.go:14: array bound must be non-negative +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug339.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug339.go new file mode 100644 index 0000000000000000000000000000000000000000..36be76170fa243f7c4b6cbedf9dcded5296c9712 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug339.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2011 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. + +// Issue 1608. +// Size used to be -1000000000. + +package main + +import "unsafe" + +func main() { + var a interface{} = 0 + size := unsafe.Sizeof(a) + if size != 2*unsafe.Sizeof((*int)(nil)) { + println("wrong size: ", size) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug340.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug340.go new file mode 100644 index 0000000000000000000000000000000000000000..117b28647a81c2f9fce8d68cb4a80adb32d1f472 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug340.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 1606. + +package main + +func main() { + var x interface{} + switch t := x.(type) { + case 0: // ERROR "type" + t.x = 1 + x.x = 1 // ERROR "type interface \{\}|reference to undefined field or method|interface with no methods|undefined" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug341.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug341.go new file mode 100644 index 0000000000000000000000000000000000000000..baab28216f681660b83274bfcfacba7fd42c7ab3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug341.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2011 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. + +// Used to panic because 8g was generating incorrect +// code for converting a negative float to a uint64. + +package main + +func main() { + var x float32 = -2.5 + + _ = uint64(x) + _ = float32(0) +} +/* +panic: runtime error: floating point error + +[signal 0x8 code=0x6 addr=0x8048c64 pc=0x8048c64] +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug342.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug342.go new file mode 100644 index 0000000000000000000000000000000000000000..ccf93a6d956c7216be9179b9760c3aacf184a9fc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug342.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 1871. + +package p + +type a interface { + foo(x int) (x int) // ERROR "duplicate argument|redefinition|redeclared" +} + +/* +Previously: + +bug.go:1 x redclared in this block + previous declaration at bug.go:1 +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug343.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug343.go new file mode 100644 index 0000000000000000000000000000000000000000..fd8bd76bbfce383685126fea1ece90d9ae6a0e88 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug343.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2011 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. + +// issue 1900 + +package main + +func getArgs(data map[string]interface{}, keys ...string) map[string]string { + ret := map[string]string{} + var ok bool + for _, k := range keys { + ret[k], ok = data[k].(string) + if !ok {} + } + return ret +} + +func main() { + x := getArgs(map[string]interface{}{"x":"y"}, "x") + if x["x"] != "y" { + println("BUG bug343", x) + } +} + + +/* +typecheck [1008592b0] +. INDREG a(1) l(15) x(24) tc(2) runtime.ret G0 string +bug343.go:15: internal compiler error: typecheck INDREG +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug344.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug344.go new file mode 100644 index 0000000000000000000000000000000000000000..b53abd26e3f114f8c33eb9b545f12de22b7cef1a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug344.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2011 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 + +import "fmt" + +func main() { + // invalid use of goto. + // do whatever you like, just don't crash. + i := 42 + a := []*int{&i, &i, &i, &i} + x := a[0] + goto start // ERROR "jumps into block" + z := 1 + _ = z + for _, x = range a { // GCCGO_ERROR "block" + start: + fmt.Sprint(*x) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug345.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug345.go new file mode 100644 index 0000000000000000000000000000000000000000..d9349fb06fa45cd20f33768b8a792072b1484a6f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug345.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2011 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug346.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug346.go new file mode 100644 index 0000000000000000000000000000000000000000..f69b58d18322e670a7f0dabff9c3ff7d51e2f868 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug346.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2011 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 + +import "os" + +func main() { + // Test unclosed closure. + { + x := 4 + a, b, c, d := func(i int) (p int, q int, r int, s int) { return 1, i, 3, x }(2) + + if a != 1 || b != 2 || c != 3 || d != 4 { + println("1# abcd: expected 1 2 3 4 got", a, b, c, d) + os.Exit(1) + } + } + // Test real closure. + { + x := 4 + gf = func(i int) (p int, q int, r int, s int) { return 1, i, 3, x } + + a, b, c, d := gf(2) + + if a != 1 || b != 2 || c != 3 || d != 4 { + println("2# abcd: expected 1 2 3 4 got", a, b, c, d) + os.Exit(1) + } + } +} + +var gf func(int) (int, int, int, int) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug347.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug347.go new file mode 100644 index 0000000000000000000000000000000000000000..92afb2e70444ff0e4cc86e45669c1075e3df3258 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug347.go @@ -0,0 +1,49 @@ +// run + +// Copyright 2011 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 + +import ( + "runtime" + "strings" +) + +var t *struct { + c chan int +} + +var c chan int + +func f() { + select { + case <-t.c: // THIS IS LINE 22 + break + case <-c: + break + } +} + +func main() { + defer func() { + recover() + for i := 0;; i++ { + pc, file, line, ok := runtime.Caller(i) + if !ok { + print("BUG: bug347: cannot find caller\n") + return + } + if !strings.Contains(file, "bug347.go") || runtime.FuncForPC(pc).Name() != "main.f" { + // walk past runtime frames + continue + } + if line != 22 { + print("BUG: bug347: panic at ", file, ":", line, " in ", runtime.FuncForPC(pc).Name(), "\n") + } + return + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug348.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug348.go new file mode 100644 index 0000000000000000000000000000000000000000..c7f134615935a34e8450dcc96241532bbefeab32 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug348.go @@ -0,0 +1,46 @@ +// run + +// Copyright 2011 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 + +import ( + "runtime" + "strings" +) + +func f() { + var x *string + + for _, i := range *x { // THIS IS LINE 17 + println(i) + } +} + +func g() { +} + +func main() { + defer func() { + for i := 0;; i++ { + pc, file, line, ok := runtime.Caller(i) + if !ok { + print("BUG: bug348: cannot find caller\n") + return + } + if !strings.Contains(file, "bug348.go") || runtime.FuncForPC(pc).Name() != "main.f" { + // walk past runtime frames + continue + } + if line != 17 { + print("BUG: bug348: panic at ", file, ":", line, " in ", runtime.FuncForPC(pc).Name(), "\n") + return + } + recover() + return + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug349.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug349.go new file mode 100644 index 0000000000000000000000000000000000000000..a6e83869a447172585a970dc790eabf0ee76a0fc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug349.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 1192 - detail in error + +package main + +func foo() (a, b, c int) { + return 0, 1 2.01 // ERROR "unexpected literal 2.01|expected ';' or '}' or newline|not enough arguments to return" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug350.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug350.go new file mode 100644 index 0000000000000000000000000000000000000000..0a8401770274b3498b3d7a19cd1e6c191d90954f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug350.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2011 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 + +type T int + +func (T) m() {} // GCCGO_ERROR "previous" +func (T) m() {} // ERROR "T\.m already declared|redefinition" + +func (*T) p() {} // GCCGO_ERROR "previous" +func (*T) p() {} // ERROR "T\.p already declared|redefinition" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug351.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug351.go new file mode 100644 index 0000000000000000000000000000000000000000..8fd63e3e95fcdd47a808ad6f91646fd687109acc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug351.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2011 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 + +var x int + +func main() { + (x) := 0 // ERROR "non-name [(]x[)]|non-name on left side" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug352.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug352.go new file mode 100644 index 0000000000000000000000000000000000000000..464ad7b8bf42e97ade9d431d62aa0ccdb61c10b9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug352.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2011 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 + +var x [10][0]byte +var y = make([]struct{}, 10) + +func main() { + if &x[1] != &x[2] { + println("BUG: bug352 [0]byte") + } + if &y[1] != &y[2] { + println("BUG: bug352 struct{}") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug353.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug353.go new file mode 100644 index 0000000000000000000000000000000000000000..4a65f7774a7ad5f496f0423b57edf2ac5c2bb2dc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug353.go @@ -0,0 +1,30 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 2089 - internal compiler error + +package main + +import ( + "io" + "os" +) + +func echo(fd io.ReadWriterCloser) { // ERROR "undefined.*io.ReadWriterCloser" + var buf [1024]byte + for { + n, err := fd.Read(buf) + if err != nil { + break + } + fd.Write(buf[0:n]) + } +} + +func main() { + fd, _ := os.Open("a.txt") + echo(fd) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug354.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug354.go new file mode 100644 index 0000000000000000000000000000000000000000..293180faee5b2ff386d07724e6c12836c839f9ee --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug354.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2011 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. + +// issue 2086 +// was calling makeclosure twice on the closure + +package bug354 + +type Inner struct { + F func() error +} + +type Outer struct { + Inners []Inner +} + +// calls makeclosure twice on same closure + +var Foo = Outer{[]Inner{Inner{func() error { return nil }}}} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug355.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug355.go new file mode 100644 index 0000000000000000000000000000000000000000..880353a90287f9c42dc6f0d39ef8fe506373ad0d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug355.go @@ -0,0 +1,18 @@ +// run + +// Copyright 2011 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 + +var f = func() int { + type S int + return 42 +} + +func main() { + if f() != 42 { + panic("BUG: bug355") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug356.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug356.go new file mode 100644 index 0000000000000000000000000000000000000000..6d93860be95c6a1043c867a2ca8b92817519b7e4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug356.go @@ -0,0 +1,41 @@ +// run + +// Copyright 2011 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. + +// issue 1808 + +package main + +func main() { + var i uint64 + var x int = 12345 + + if y := x << (i&5); y != 12345<<0 { + println("BUG bug344", y) + return + } + + i++ + if y := x << (i&5); y != 12345<<1 { + println("BUG bug344a", y) + } + + i = 70 + if y := x << i; y != 0 { + println("BUG bug344b", y) + } + + i = 1<<32 + if y := x << i; y != 0 { + println("BUG bug344c", y) + } +} + + +/* +typecheck [1008592b0] +. INDREG a(1) l(15) x(24) tc(2) runtime.ret G0 string +bug343.go:15: internal compiler error: typecheck INDREG +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug357.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug357.go new file mode 100644 index 0000000000000000000000000000000000000000..0a4cbedd95ec6efa9d6e10b1158acf54d753b659 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug357.go @@ -0,0 +1,26 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 1993. +// error used to have last line number in file + +package main + +func bla1() bool { + return false +} + +func bla5() bool { + _ = 1 + false // ERROR "false evaluated but not used|value computed is not used|is not used" + _ = 2 + return false +} + +func main() { + x := bla1() + _ = x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug358.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug358.go new file mode 100644 index 0000000000000000000000000000000000000000..541051cdd3e8eab4d2ff3c476d4f6c58db6b2fd6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug358.go @@ -0,0 +1,27 @@ +// errorcheck -d=panic + +// Copyright 2011 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. + +// issue 1979 +// used to get internal compiler error too + +package main + +import ( + // avoid imported and not used errors + // "io/ioutil" + "net/http" + // "os" +) + +func makeHandler(fn func(http.ResponseWriter, *http.Request, string)) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) // ERROR "syntax error|not an expression|invalid use of type" +} + +type Page struct { + Title string + Body []byte +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug361.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug361.go new file mode 100644 index 0000000000000000000000000000000000000000..8e282431eb394350281390267db2cd7c9827ee60 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug361.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2011 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. + +// issue 1908 +// unreasonable width used to be internal fatal error + +package test + +func main() { + buf := [1<<30]byte{} + _ = buf[:] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug362.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug362.go new file mode 100644 index 0000000000000000000000000000000000000000..98d6b0c82289ada9d1f90ce40da9a21e6426f577 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug362.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 1662 +// iota inside var + +package main + +var ( + a = iota // ERROR "undefined: iota|iota is only defined in const|cannot use iota outside constant declaration" + b = iota // ERROR "undefined: iota|iota is only defined in const|cannot use iota outside constant declaration" + c = iota // ERROR "undefined: iota|iota is only defined in const|cannot use iota outside constant declaration" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug363.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug363.go new file mode 100644 index 0000000000000000000000000000000000000000..1bd1400987d1b1bc139e5540423f3d46a36e6a57 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug363.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 1664 + +package main + +func main() { + var i uint = 33 + var a = (1<>1 + } + return s +} + +func main() { + x := -f(100) + if x != -2450 { + println(x) + panic("broken") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug369.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug369.go new file mode 100644 index 0000000000000000000000000000000000000000..f5dad370dbee6eda6ee9c27015dcf0037684efe2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug369.go @@ -0,0 +1,62 @@ +// run + +//go:build !nacl && !js && !wasip1 && gc + +// Copyright 2011 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. + +// Test that compiling with optimization turned on produces faster code. + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" + "path/filepath" +) + +func main() { + err := os.Chdir(filepath.Join(".", "fixedbugs", "bug369.dir")) + check(err) + + tmpDir, err := ioutil.TempDir("", "bug369") + check(err) + defer os.RemoveAll(tmpDir) + + tmp := func(name string) string { + return filepath.Join(tmpDir, name) + } + + check(os.Mkdir(tmp("test"), 0777)) + + stdlibimportcfg, err := os.ReadFile(os.Getenv("STDLIB_IMPORTCFG")) + check(err) + importcfg := string(stdlibimportcfg) + "\npackagefile test/slow=" + tmp("test/slow.o") + "\npackagefile test/fast=" + tmp("test/fast.o") + os.WriteFile(tmp("importcfg"), []byte(importcfg), 0644) + + run("go", "tool", "compile", "-importcfg="+tmp("importcfg"), "-p=test/slow", "-N", "-o", tmp("test/slow.o"), "pkg.go") + run("go", "tool", "compile", "-importcfg="+tmp("importcfg"), "-p=test/fast", "-o", tmp("test/fast.o"), "pkg.go") + run("go", "tool", "compile", "-importcfg="+tmp("importcfg"), "-p=main", "-D", "test", "-o", tmp("main.o"), "main.go") + run("go", "tool", "link", "-importcfg="+tmp("importcfg"), "-o", tmp("a.exe"), tmp("main.o")) + run(tmp("a.exe")) +} + +func run(name string, args ...string) { + cmd := exec.Command(name, args...) + out, err := cmd.CombinedOutput() + if err != nil { + fmt.Println(string(out)) + fmt.Println(err) + os.Exit(1) + } +} + +func check(err error) { + if err != nil { + fmt.Println(err) + os.Exit(1) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug370.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug370.go new file mode 100644 index 0000000000000000000000000000000000000000..c5165c52ccf7cb952e56249685db060f2c724a61 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug370.go @@ -0,0 +1,18 @@ +// run + +// Copyright 2011 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 + +// issue 2337 +// The program deadlocked. + +import "runtime" + +func main() { + runtime.GOMAXPROCS(2) + runtime.GC() + runtime.GOMAXPROCS(1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug371.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug371.go new file mode 100644 index 0000000000000000000000000000000000000000..eb51b9ee86ec6597df9e8af7e6a80952a452cbde --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug371.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 2343 + +package main + +type T struct{} + +func (t *T) pm() {} +func (t T) m() {} + +func main() { + p := &T{} + p.pm() + p.m() + + q := &p + q.m() // ERROR "requires explicit dereference|undefined" + q.pm() // ERROR "requires explicit dereference|undefined" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug372.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug372.go new file mode 100644 index 0000000000000000000000000000000000000000..5fba131d7a22938543bbf75d1e3087f6cc1de433 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug372.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2011 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. + +// Issue 2355 +package main + +type T struct {} +func (T) m() string { return "T" } + +type TT struct { + T + m func() string +} + + +func ff() string { return "ff" } + +func main() { + var tt TT + tt.m = ff + + if tt.m() != "ff" { + println(tt.m(), "!= \"ff\"") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug373.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug373.go new file mode 100644 index 0000000000000000000000000000000000000000..aa0f5d1efa685d0912e8e017b6b3c2b0ef00881e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug373.go @@ -0,0 +1,32 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 873, 2162 + +package foo + +func f(x interface{}) { + switch t := x.(type) { // ERROR "declared and not used" + case int: + } +} + +func g(x interface{}) { + switch t := x.(type) { + case int: + case float32: + println(t) + } +} + +func h(x interface{}) { + switch t := x.(type) { + case int: + case float32: + default: + println(t) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug374.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug374.go new file mode 100644 index 0000000000000000000000000000000000000000..2d604cbd3c6bda02763223b9fbc8a7b30b3924ca --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug374.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 1556 +package foo + +type I interface { + m() int +} + +type T int + +var _ I = T(0) // GCCGO_ERROR "incompatible" + +func (T) m(buf []byte) (a int, b xxxx) { // ERROR "xxxx" + return 0, nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug375.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug375.go new file mode 100644 index 0000000000000000000000000000000000000000..08d5afc894ddc519071e1929b9da1289e72238e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug375.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2011 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. + +// Issue 2423 + +package main + +func main() { + var x interface{} = "hello" + + switch x { + case "hello": + default: + println("FAIL") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug376.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug376.go new file mode 100644 index 0000000000000000000000000000000000000000..cd700124fe59d6218e19fce28b46ca528f237672 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug376.go @@ -0,0 +1,10 @@ +// errorcheck + +// Copyright 2011 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. + +// issue 1951 +package foo +import "unsafe" +var v = unsafe.Sizeof // ERROR "not in function call|must be called" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug377.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug377.go new file mode 100644 index 0000000000000000000000000000000000000000..22df005b2a23708eec061a23c8816adc748b7683 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug377.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2011 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. + +// Issue 1802 + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug378.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug378.go new file mode 100644 index 0000000000000000000000000000000000000000..c7b0dac31324b8031c57f09738cac76d37fe68f8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug378.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2011 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. + +// Issue 2497 + +package main + +type Header struct{} +func (h Header) Method() {} + +var _ interface{} = Header{} + +func main() { + type X Header + var _ interface{} = X{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug379.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug379.go new file mode 100644 index 0000000000000000000000000000000000000000..aa078b6ff45c30158817a9268f36ccc48ab97c60 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug379.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2452. + +// Check that the error messages says +// bug378.go:17: 1 + 2 not used +// and not +// bug378.go:17: 1 not used + +package main + +func main() { + 1 + 2 // ERROR "1 \+ 2 evaluated but not used|value computed is not used|is not used" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug380.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug380.go new file mode 100644 index 0000000000000000000000000000000000000000..0cb34873272ba8b894d5a92d595009321f7078c8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug380.go @@ -0,0 +1,11 @@ +// compile + +// Copyright 2011 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. + +// Used to cause a typechecking loop error. + +package pkg +type T map[int]string +var q = &T{} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug381.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug381.go new file mode 100644 index 0000000000000000000000000000000000000000..a0a1c8aaa44ce43128285e0c6c29447bd3116304 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug381.go @@ -0,0 +1,31 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2276. + +// Check that the error messages says +// bug381.go:29: unsafe.Alignof(0) not used +// and not +// bug381.go:29: 4 not used + +// Issue 2768: previously got +// bug381.go:30: cannot use 3 (type time.Weekday) as type int in function argument +// want +// bug381.go:30: cannot use time.Wednesday (type time.Weekday) as type int in function argument + +package main + +import ( + "time" + "unsafe" +) + +func f(int) + +func main() { + unsafe.Alignof(0) // ERROR "unsafe\.Alignof|value computed is not used" + f(time.Wednesday) // ERROR "time.Wednesday|incompatible type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug382.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug382.go new file mode 100644 index 0000000000000000000000000000000000000000..6039939eeb880266dd1795e15e1d8b01421b361f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug382.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2011 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 + +// Issue 2529. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug383.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug383.go new file mode 100644 index 0000000000000000000000000000000000000000..543ee10ac6065710977688fee44e06d1304f005e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug383.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2520 + +package main +func main() { + if 2e9 { } // ERROR "2e.09|expected bool|non-boolean condition in if statement" + if 3.14+1i { } // ERROR "3.14 . 1i|expected bool|non-boolean condition in if statement" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug384.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug384.go new file mode 100644 index 0000000000000000000000000000000000000000..d02352b47845264e6963762050f500c61c3f440e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug384.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2500 + +package foo + +// Check that we only get root cause message, no further complaints about r undefined +func (r *indexWriter) foo() {} // ERROR "undefined.*indexWriter" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug385_32.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug385_32.go new file mode 100644 index 0000000000000000000000000000000000000000..d9314c7e5d809f6d102aaee310f7a90001e6414b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug385_32.go @@ -0,0 +1,16 @@ +// errorcheck + +//go:build 386 || amd64p32 || arm + +// Copyright 2011 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. + +// Issue 2444 + +package main +func main() { + var arr [1000200030]int // GC_ERROR "type .* too large" + arr_bkup := arr + _ = arr_bkup +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug385_64.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug385_64.go new file mode 100644 index 0000000000000000000000000000000000000000..3240960f1ad35a072a45dee8e3f09db8d3ab07af --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug385_64.go @@ -0,0 +1,224 @@ +// errorcheck + +//go:build amd64 + +// Copyright 2011 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. + +// Issue 2444 +// Issue 4666: issue with arrays of exactly 4GB. + +package main + +var z [10<<20]byte + +func main() { // GC_ERROR "stack frame too large" + // seq 1 206 | sed 's/.*/ var x& [10<<20]byte; z = x&/' + var x1 [10<<20]byte; z = x1 + var x2 [10<<20]byte; z = x2 + var x3 [10<<20]byte; z = x3 + var x4 [10<<20]byte; z = x4 + var x5 [10<<20]byte; z = x5 + var x6 [10<<20]byte; z = x6 + var x7 [10<<20]byte; z = x7 + var x8 [10<<20]byte; z = x8 + var x9 [10<<20]byte; z = x9 + var x10 [10<<20]byte; z = x10 + var x11 [10<<20]byte; z = x11 + var x12 [10<<20]byte; z = x12 + var x13 [10<<20]byte; z = x13 + var x14 [10<<20]byte; z = x14 + var x15 [10<<20]byte; z = x15 + var x16 [10<<20]byte; z = x16 + var x17 [10<<20]byte; z = x17 + var x18 [10<<20]byte; z = x18 + var x19 [10<<20]byte; z = x19 + var x20 [10<<20]byte; z = x20 + var x21 [10<<20]byte; z = x21 + var x22 [10<<20]byte; z = x22 + var x23 [10<<20]byte; z = x23 + var x24 [10<<20]byte; z = x24 + var x25 [10<<20]byte; z = x25 + var x26 [10<<20]byte; z = x26 + var x27 [10<<20]byte; z = x27 + var x28 [10<<20]byte; z = x28 + var x29 [10<<20]byte; z = x29 + var x30 [10<<20]byte; z = x30 + var x31 [10<<20]byte; z = x31 + var x32 [10<<20]byte; z = x32 + var x33 [10<<20]byte; z = x33 + var x34 [10<<20]byte; z = x34 + var x35 [10<<20]byte; z = x35 + var x36 [10<<20]byte; z = x36 + var x37 [10<<20]byte; z = x37 + var x38 [10<<20]byte; z = x38 + var x39 [10<<20]byte; z = x39 + var x40 [10<<20]byte; z = x40 + var x41 [10<<20]byte; z = x41 + var x42 [10<<20]byte; z = x42 + var x43 [10<<20]byte; z = x43 + var x44 [10<<20]byte; z = x44 + var x45 [10<<20]byte; z = x45 + var x46 [10<<20]byte; z = x46 + var x47 [10<<20]byte; z = x47 + var x48 [10<<20]byte; z = x48 + var x49 [10<<20]byte; z = x49 + var x50 [10<<20]byte; z = x50 + var x51 [10<<20]byte; z = x51 + var x52 [10<<20]byte; z = x52 + var x53 [10<<20]byte; z = x53 + var x54 [10<<20]byte; z = x54 + var x55 [10<<20]byte; z = x55 + var x56 [10<<20]byte; z = x56 + var x57 [10<<20]byte; z = x57 + var x58 [10<<20]byte; z = x58 + var x59 [10<<20]byte; z = x59 + var x60 [10<<20]byte; z = x60 + var x61 [10<<20]byte; z = x61 + var x62 [10<<20]byte; z = x62 + var x63 [10<<20]byte; z = x63 + var x64 [10<<20]byte; z = x64 + var x65 [10<<20]byte; z = x65 + var x66 [10<<20]byte; z = x66 + var x67 [10<<20]byte; z = x67 + var x68 [10<<20]byte; z = x68 + var x69 [10<<20]byte; z = x69 + var x70 [10<<20]byte; z = x70 + var x71 [10<<20]byte; z = x71 + var x72 [10<<20]byte; z = x72 + var x73 [10<<20]byte; z = x73 + var x74 [10<<20]byte; z = x74 + var x75 [10<<20]byte; z = x75 + var x76 [10<<20]byte; z = x76 + var x77 [10<<20]byte; z = x77 + var x78 [10<<20]byte; z = x78 + var x79 [10<<20]byte; z = x79 + var x80 [10<<20]byte; z = x80 + var x81 [10<<20]byte; z = x81 + var x82 [10<<20]byte; z = x82 + var x83 [10<<20]byte; z = x83 + var x84 [10<<20]byte; z = x84 + var x85 [10<<20]byte; z = x85 + var x86 [10<<20]byte; z = x86 + var x87 [10<<20]byte; z = x87 + var x88 [10<<20]byte; z = x88 + var x89 [10<<20]byte; z = x89 + var x90 [10<<20]byte; z = x90 + var x91 [10<<20]byte; z = x91 + var x92 [10<<20]byte; z = x92 + var x93 [10<<20]byte; z = x93 + var x94 [10<<20]byte; z = x94 + var x95 [10<<20]byte; z = x95 + var x96 [10<<20]byte; z = x96 + var x97 [10<<20]byte; z = x97 + var x98 [10<<20]byte; z = x98 + var x99 [10<<20]byte; z = x99 + var x100 [10<<20]byte; z = x100 + var x101 [10<<20]byte; z = x101 + var x102 [10<<20]byte; z = x102 + var x103 [10<<20]byte; z = x103 + var x104 [10<<20]byte; z = x104 + var x105 [10<<20]byte; z = x105 + var x106 [10<<20]byte; z = x106 + var x107 [10<<20]byte; z = x107 + var x108 [10<<20]byte; z = x108 + var x109 [10<<20]byte; z = x109 + var x110 [10<<20]byte; z = x110 + var x111 [10<<20]byte; z = x111 + var x112 [10<<20]byte; z = x112 + var x113 [10<<20]byte; z = x113 + var x114 [10<<20]byte; z = x114 + var x115 [10<<20]byte; z = x115 + var x116 [10<<20]byte; z = x116 + var x117 [10<<20]byte; z = x117 + var x118 [10<<20]byte; z = x118 + var x119 [10<<20]byte; z = x119 + var x120 [10<<20]byte; z = x120 + var x121 [10<<20]byte; z = x121 + var x122 [10<<20]byte; z = x122 + var x123 [10<<20]byte; z = x123 + var x124 [10<<20]byte; z = x124 + var x125 [10<<20]byte; z = x125 + var x126 [10<<20]byte; z = x126 + var x127 [10<<20]byte; z = x127 + var x128 [10<<20]byte; z = x128 + var x129 [10<<20]byte; z = x129 + var x130 [10<<20]byte; z = x130 + var x131 [10<<20]byte; z = x131 + var x132 [10<<20]byte; z = x132 + var x133 [10<<20]byte; z = x133 + var x134 [10<<20]byte; z = x134 + var x135 [10<<20]byte; z = x135 + var x136 [10<<20]byte; z = x136 + var x137 [10<<20]byte; z = x137 + var x138 [10<<20]byte; z = x138 + var x139 [10<<20]byte; z = x139 + var x140 [10<<20]byte; z = x140 + var x141 [10<<20]byte; z = x141 + var x142 [10<<20]byte; z = x142 + var x143 [10<<20]byte; z = x143 + var x144 [10<<20]byte; z = x144 + var x145 [10<<20]byte; z = x145 + var x146 [10<<20]byte; z = x146 + var x147 [10<<20]byte; z = x147 + var x148 [10<<20]byte; z = x148 + var x149 [10<<20]byte; z = x149 + var x150 [10<<20]byte; z = x150 + var x151 [10<<20]byte; z = x151 + var x152 [10<<20]byte; z = x152 + var x153 [10<<20]byte; z = x153 + var x154 [10<<20]byte; z = x154 + var x155 [10<<20]byte; z = x155 + var x156 [10<<20]byte; z = x156 + var x157 [10<<20]byte; z = x157 + var x158 [10<<20]byte; z = x158 + var x159 [10<<20]byte; z = x159 + var x160 [10<<20]byte; z = x160 + var x161 [10<<20]byte; z = x161 + var x162 [10<<20]byte; z = x162 + var x163 [10<<20]byte; z = x163 + var x164 [10<<20]byte; z = x164 + var x165 [10<<20]byte; z = x165 + var x166 [10<<20]byte; z = x166 + var x167 [10<<20]byte; z = x167 + var x168 [10<<20]byte; z = x168 + var x169 [10<<20]byte; z = x169 + var x170 [10<<20]byte; z = x170 + var x171 [10<<20]byte; z = x171 + var x172 [10<<20]byte; z = x172 + var x173 [10<<20]byte; z = x173 + var x174 [10<<20]byte; z = x174 + var x175 [10<<20]byte; z = x175 + var x176 [10<<20]byte; z = x176 + var x177 [10<<20]byte; z = x177 + var x178 [10<<20]byte; z = x178 + var x179 [10<<20]byte; z = x179 + var x180 [10<<20]byte; z = x180 + var x181 [10<<20]byte; z = x181 + var x182 [10<<20]byte; z = x182 + var x183 [10<<20]byte; z = x183 + var x184 [10<<20]byte; z = x184 + var x185 [10<<20]byte; z = x185 + var x186 [10<<20]byte; z = x186 + var x187 [10<<20]byte; z = x187 + var x188 [10<<20]byte; z = x188 + var x189 [10<<20]byte; z = x189 + var x190 [10<<20]byte; z = x190 + var x191 [10<<20]byte; z = x191 + var x192 [10<<20]byte; z = x192 + var x193 [10<<20]byte; z = x193 + var x194 [10<<20]byte; z = x194 + var x195 [10<<20]byte; z = x195 + var x196 [10<<20]byte; z = x196 + var x197 [10<<20]byte; z = x197 + var x198 [10<<20]byte; z = x198 + var x199 [10<<20]byte; z = x199 + var x200 [10<<20]byte; z = x200 + var x201 [10<<20]byte; z = x201 + var x202 [10<<20]byte; z = x202 + var x203 [10<<20]byte; z = x203 + var x204 [10<<20]byte; z = x204 + var x205 [10<<20]byte; z = x205 + var x206 [10<<20]byte; z = x206 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug386.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug386.go new file mode 100644 index 0000000000000000000000000000000000000000..0899d1fc216b87a60d2b323f22ce3f9f0eb6f56b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug386.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2451, 2452 +package foo + +func f() error { return 0 } // ERROR "cannot use 0 (.type int.)?|has no methods" + +func g() error { return -1 } // ERROR "cannot use -1 (.type int.)?|has no methods" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug387.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug387.go new file mode 100644 index 0000000000000000000000000000000000000000..d8854457446fc9076b6afc2ba61533f4f1423e52 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug387.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2011 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. + +// Issue 2549 + +/* Used to die with +missing typecheck: [7f5bf07b4438] + +. AS l(45) +. . NAME-main.autotmp_0017 u(1) a(1) l(45) x(0+0) class(PAUTO) +esc(N) tc(1) used(1) ARRAY-[2]string +internal compiler error: missing typecheck +*/ +package main + +import ( + "fmt" + "path/filepath" +) + +func main() { + switch _, err := filepath.Glob(filepath.Join(".", "vnc")); { + case err != nil: + fmt.Println(err) + } +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug388.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug388.go new file mode 100644 index 0000000000000000000000000000000000000000..a060c9fd5a75c66e0f676f37f2dbe32665f5eb0f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug388.go @@ -0,0 +1,29 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2231 + +package main +import "runtime" + +func foo(runtime.UintType, i int) { // ERROR "cannot declare name runtime.UintType|mixed named and unnamed|undefined identifier" + println(i, runtime.UintType) // GCCGO_ERROR "undefined identifier" +} + +func qux() { + var main.i // ERROR "unexpected [.]|expected type" + println(main.i) +} + +func corge() { + var foo.i int // ERROR "unexpected [.]|expected type" + println(foo.i) +} + +func main() { + foo(42,43) + bar(1969) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug388a.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug388a.go new file mode 100644 index 0000000000000000000000000000000000000000..fca6d9c1e4b8a952b63e3a229ad65ef29b9107e2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug388a.go @@ -0,0 +1,23 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2231 + +package main +import "runtime" + +func bar(i int) { + runtime.UintType := i // ERROR "non-name runtime.UintType|non-name on left side|undefined" + println(runtime.UintType) // ERROR "invalid use of type|undefined" +} + +func baz() { + main.i := 1 // ERROR "non-name main.i|non-name on left side|undefined" + println(main.i) // ERROR "no fields or methods|undefined" +} + +func main() { +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug389.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug389.go new file mode 100644 index 0000000000000000000000000000000000000000..3e8adb97285876ebdfb1056965aa3a2d99620f42 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug389.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2563 +package foo + +func fn(a float32) {} + +var f func(arg int) = fn // ERROR "different parameter types|cannot use fn .*type func.*float32.. as func.*int. value in variable declaration" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug390.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug390.go new file mode 100644 index 0000000000000000000000000000000000000000..4ab24fb521a3dbd6650474a6be99c21f3152937b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug390.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2627 -- unsafe.Pointer type isn't handled nicely in some errors + +package main + +import "unsafe" + +func main() { + var x *int + _ = unsafe.Pointer(x) - unsafe.Pointer(x) // ERROR "(operator|operation) - not defined on unsafe.Pointer|expected integer, floating, or complex type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug391.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug391.go new file mode 100644 index 0000000000000000000000000000000000000000..9211b1c2cf4992464197265aea998d2b27c1b0d7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug391.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2011 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. + +// Issue 2576 +package bug + +type T struct { a int } + +func f(t T) { + switch _, _ = t.a, t.a; {} +} \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug392.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug392.go new file mode 100644 index 0000000000000000000000000000000000000000..48b79e01b894a128edb9c5c4a839674a5ead3156 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug392.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2011 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug393.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug393.go new file mode 100644 index 0000000000000000000000000000000000000000..61af578c5310471ac5428797e4991e4f37f0bcb3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug393.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2012 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. + +// issue 2672 +// was trying binary search with an interface type + +package bug393 + +func f(x interface{}) int { + switch x { + case 1: + return 1 + case 2: + return 2 + case 3: + return 3 + case 4: + return 4 + case "5": + return 5 + case "6": + return 6 + default: + return 7 + } + panic("switch") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug394.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug394.go new file mode 100644 index 0000000000000000000000000000000000000000..08bac182f704b6a1e9923c08affad872c63d65a0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug394.go @@ -0,0 +1,10 @@ +// errorcheck + +// Copyright 2011 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. + +// Issue 2598 +package foo + +return nil // ERROR "non-declaration statement outside function body|expected declaration" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug396.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug396.go new file mode 100644 index 0000000000000000000000000000000000000000..48b79e01b894a128edb9c5c4a839674a5ead3156 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug396.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2011 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug397.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug397.go new file mode 100644 index 0000000000000000000000000000000000000000..5f1476adf7898a9913448afb54b6df0438760e21 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug397.go @@ -0,0 +1,13 @@ +// errorcheck -d=panic + +// Copyright 2011 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 + +// Issue 2623 +var m = map[string]int{ + "abc": 1, + 1: 2, // ERROR "cannot use 1.*as type string in map key|incompatible type|cannot convert|cannot use" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug398.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug398.go new file mode 100644 index 0000000000000000000000000000000000000000..2b00f6074d4c39099582c5fdc85f9a609a1a51a2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug398.go @@ -0,0 +1,44 @@ +// errorcheck + +// Copyright 2012 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. + +// Used to crash compiler in interface type equality check. +// (This test used to have problems - see #15596.) + +package p + +// exported interfaces + +type I1 interface { // ERROR "invalid recursive type: anonymous interface refers to itself" + F() interface{I1} +} + +type I2 interface { // ERROR "invalid recursive type: anonymous interface refers to itself" + F() interface{I2} +} + +var V1 I1 +var V2 I2 + +func F() bool { + return V1 == V2 +} + +// non-exported interfaces + +type i1 interface { // ERROR "invalid recursive type: anonymous interface refers to itself" + F() interface{i1} +} + +type i2 interface { // ERROR "invalid recursive type: anonymous interface refers to itself" + F() interface{i2} +} + +var v1 i1 +var v2 i2 + +func f() bool { + return v1 == v2 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug399.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug399.go new file mode 100644 index 0000000000000000000000000000000000000000..e460d812277d1627cd9f7d78e16bfd839a1adac0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug399.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2011 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. + +// Issue 2674 + +package main +const dow = "\000\003" + +func main() { + println(int(dow[1])) +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug401.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug401.go new file mode 100644 index 0000000000000000000000000000000000000000..215498e085707eba846f6af3594d10608b85636f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug401.go @@ -0,0 +1,45 @@ +// run + +// Copyright 2011 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. + +// Issue 2582 +package main + +type T struct{} + +//go:noinline +func (T) cplx() complex128 { + return complex(1, 0) +} + +func (T) cplx2() complex128 { + return complex(0, 1) +} + +type I interface { + cplx() complex128 +} + +func main() { + + var t T + + if v := real(t.cplx()); v != 1 { + panic("not-inlined complex call failed") + } + _ = imag(t.cplx()) + + _ = real(t.cplx2()) + if v := imag(t.cplx2()); v != 1 { + panic("potentially inlined complex call failed") + } + + var i I + i = t + if v := real(i.cplx()); v != 1 { + panic("potentially inlined complex call failed") + } + _ = imag(i.cplx()) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug402.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug402.go new file mode 100644 index 0000000000000000000000000000000000000000..f9f554d817daa48d5dcf2e2b2c1ad104a0bc1528 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug402.go @@ -0,0 +1,31 @@ +// run + +// Copyright 2012 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 + +import "fmt" + +var a = []int64{ + 0.0005 * 1e9, + 0.001 * 1e9, + 0.005 * 1e9, + 0.01 * 1e9, + 0.05 * 1e9, + 0.1 * 1e9, + 0.5 * 1e9, + 1 * 1e9, + 5 * 1e9, +} + +func main() { + s := "" + for _, v := range a { + s += fmt.Sprint(v) + " " + } + if s != "500000 1000000 5000000 10000000 50000000 100000000 500000000 1000000000 5000000000 " { + panic(s) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug403.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug403.go new file mode 100644 index 0000000000000000000000000000000000000000..aa3c1ea61fa7265e78b3e7e634a05d37c8440330 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug403.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2012 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. + +// Crashed gccgo. + +package p + +type S struct { + f interface{} +} + +func F(p *S) bool { + v := p.f + switch a := v.(type) { + case nil: + _ = a + return true + } + return true +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug404.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug404.go new file mode 100644 index 0000000000000000000000000000000000000000..481acda3284a8f2554c4b7b91932b0e9e25568bc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug404.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2012 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug405.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug405.go new file mode 100644 index 0000000000000000000000000000000000000000..e8ecc4d034afaeb4c17b08c2fc4e027b32de0191 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug405.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2012 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. + +// Test using _ receiver. Failed with gccgo. + +package main + +type S struct {} + +func (_ S) F(i int) int { + return i +} + +func main() { + s := S{} + const c = 123 + i := s.F(c) + if i != c { + panic(i) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug406.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug406.go new file mode 100644 index 0000000000000000000000000000000000000000..32cf3e35d278e58be97176f45223762102887f70 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug406.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2012 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. + +// Issue 2821 +package main + +type matrix struct { + e []int +} + +func (a matrix) equal() bool { + for _ = range a.e { + } + for range a.e { + } + return true +} + +func main() { + var a matrix + var i interface{} + i = true && a.equal() + _ = i +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug407.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug407.go new file mode 100644 index 0000000000000000000000000000000000000000..48b79e01b894a128edb9c5c4a839674a5ead3156 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug407.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2011 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug409.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug409.go new file mode 100644 index 0000000000000000000000000000000000000000..e8546361ab49343d34083131cb0aed0327bee134 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug409.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2012 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. + +// Multiple inlined calls to a function that causes +// redundant address loads. + +package main + +func F(v [2]float64) [2]float64 { + return [2]float64{v[0], v[1]} +} + +func main() { + a := F([2]float64{1, 2}) + b := F([2]float64{3, 4}) + println(a[0], a[1], b[0], b[1]) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug409.out b/platform/dbops/binaries/go/go/test/fixedbugs/bug409.out new file mode 100644 index 0000000000000000000000000000000000000000..3cb40ed59a9c19d1db75d17d3996996216668966 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug409.out @@ -0,0 +1 @@ ++1.000000e+000 +2.000000e+000 +3.000000e+000 +4.000000e+000 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug410.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug410.go new file mode 100644 index 0000000000000000000000000000000000000000..a4eef64d8e911f4c67999b8db966ac7a33b60e5b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug410.go @@ -0,0 +1,24 @@ +// compile + +// Copyright 2012 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. + +// Used to run 6g out of registers. Issue 2669. + +package p + +type y struct { + num int +} + +func zzz () { + k := make([]byte, 10) + arr := make ([]*y, 0) + for s := range arr { + x := make([]byte, 10) + for i := 0; i < 100 ; i++ { + x[i] ^= k[i-arr[s].num%3] + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug411.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug411.go new file mode 100644 index 0000000000000000000000000000000000000000..a1c36f617c7c06b37107f2aaea65836bd86c34ca --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug411.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2012 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. + +// Issue 2588. Used to trigger internal compiler error on 8g, +// because the compiler tried to registerize the int64 being +// used as a memory operand of a int64->float64 move. + +package p + +func f1(a int64) { + f2(float64(a), float64(a)) +} + +func f2(a,b float64) { +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug412.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug412.go new file mode 100644 index 0000000000000000000000000000000000000000..26ac45fbb40a38440818e99f65831e5df5c86f52 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug412.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2012 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 p + +type t struct { + x int // GCCGO_ERROR "duplicate field name .x." + x int // GC_ERROR "duplicate field x|x redeclared" +} + +func f(t *t) int { + return t.x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug413.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug413.go new file mode 100644 index 0000000000000000000000000000000000000000..e22279e15c5daf9b44df60f19ba07d565e1df58e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug413.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2012 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 p + +func f(i int) int { return i } + +var i = func() int {a := f(i); return a}() // ERROR "initialization cycle|depends upon itself" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug414.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug414.go new file mode 100644 index 0000000000000000000000000000000000000000..5b435b4aeb9138aa5cd7c91e5000c009329d4c51 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug414.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2012 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. + +// Issue 1743: test embedding of imported types with private methods. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug415.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug415.go new file mode 100644 index 0000000000000000000000000000000000000000..daf4f0c8ce41c3d9344b7296e2aba42781d61461 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug415.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2012 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. + +// Issue 2716. Export metadata error made main.go not compile. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug416.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug416.go new file mode 100644 index 0000000000000000000000000000000000000000..74b55cce18ae02b8f5ae6e28fb1c24cf7b21a106 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug416.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2012 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 p + +type T struct { + X int +} + +func (t *T) X() {} // ERROR "type T has both field and method named X|redeclares struct field name|field and method with the same name" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug417.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug417.go new file mode 100644 index 0000000000000000000000000000000000000000..a9acb42386addd897a8528332210e4ab549972fe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug417.go @@ -0,0 +1,32 @@ +// compile + +// 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. + +// Some indirect uses of types crashed gccgo, because it assumed that +// the size of the type was known before it had been computed. + +package p + +type S1 struct { + p *[1]S3 + s [][1]S3 + m map[int][1]S3 + c chan [1]S3 + i interface { f([1]S3) [1]S3 } + f func([1]S3) [1]S3 +} + +type S2 struct { + p *struct { F S3 } + s []struct { F S3 } + m map[int]struct { F S3 } + c chan struct { F S3 } + i interface { f(struct { F S3 }) struct { F S3 } } + f func(struct { F S3 } ) struct { F S3 } +} + +type S3 struct { + I int +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug418.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug418.go new file mode 100644 index 0000000000000000000000000000000000000000..4e63e867b852669720b40ac84c15c8692ed23437 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug418.go @@ -0,0 +1,22 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 3044. +// Multiple valued expressions in return lists. + +package p + +func Two() (a, b int) + +// F used to compile. +func F() (x interface{}, y int) { + return Two(), 0 // ERROR "single-value context|2\-valued" +} + +// Recursive used to trigger an internal compiler error. +func Recursive() (x interface{}, y int) { + return Recursive(), 0 // ERROR "single-value context|2\-valued" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug419.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug419.go new file mode 100644 index 0000000000000000000000000000000000000000..cfab404eb35c06c2777b0e817ecd6474b8739159 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug419.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2012 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. + +// Issue 1811. +// gccgo failed to compile this. + +package p + +type E interface{} + +type I interface { + E + E +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug420.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug420.go new file mode 100644 index 0000000000000000000000000000000000000000..02b4349d807ac048864924806fa9830479af8a44 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug420.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2012 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. + +// Issue 1757. +// gccgo failed to compile this. + +package main + +func main() { + (_) = 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug421.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug421.go new file mode 100644 index 0000000000000000000000000000000000000000..1fe02375ab6956942a785839c4d07d5b496ab7a7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug421.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 1927. +// gccgo failed to issue the first error below. + +package main + +func main() { + println(int(1) == uint(1)) // ERROR "types" + var x int = 1 + var y uint = 1 + println(x == y) // ERROR "types" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug422.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug422.go new file mode 100644 index 0000000000000000000000000000000000000000..6865fe4b63fe76d15cd9cf4b500c8dc95ebf8e96 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug422.go @@ -0,0 +1,11 @@ +// compile + +// Copyright 2012 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. + +// gccgo crashed compiling this file. + +package p + +var V = "a" > "b" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug423.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug423.go new file mode 100644 index 0000000000000000000000000000000000000000..7268912454268c72300762a23573c695949dd6b7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug423.go @@ -0,0 +1,277 @@ +// run + +// Copyright 2012 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. + +// gc used to overflow a counter when a variable was +// mentioned 256 times, and generate stack corruption. + +package main + +func main() { + F(1) +} + +func F(arg int) { + var X interface{} + _ = X // used once + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 32 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 64 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 96 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 128 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 200 times + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 + X = 0 // used 256 times + if arg != 1 { + panic("argument was changed") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug424.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug424.go new file mode 100644 index 0000000000000000000000000000000000000000..9c59abe8026bfecfdf857d8b2a13a4d8fe551ad1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug424.go @@ -0,0 +1,13 @@ +// rundir + +// Copyright 2012 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. + +// Tests that method calls through an interface always +// call the locally defined method localT.m independent +// at which embedding level it is and in which order +// embedding is done. + +package ignored + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug425.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug425.go new file mode 100644 index 0000000000000000000000000000000000000000..c3035f6a915911840fdb9b4a7bf08ae15ca2e7da --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug425.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2012 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. + +// https://golang.org/issue/3119 + +package main + +import "fmt" + +func main() { + s := "hello" + fmt.Println(s == "") + fmt.Println(s + "world" == "world") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug426.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug426.go new file mode 100644 index 0000000000000000000000000000000000000000..a1af3cf997d71f6202a2b47a80f6e0474284dc87 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug426.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2012 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. + +// gccgo crashed compiling this. + +package p + +type T *T + +func f(t T) { + println(t, *t) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug427.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug427.go new file mode 100644 index 0000000000000000000000000000000000000000..c13bb815ca402ed0f063e033cf23b68c242eea55 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug427.go @@ -0,0 +1,39 @@ +// compile + +// Copyright 2012 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. + +// https://golang.org/issue/3351 + +package main + +// struct with four fields of basic type +type S struct {a, b, c, d int} + +// struct with five fields of basic type +type T struct {a, b, c, d, e int} + +// array with four elements +type A [4]int + +// array with five elements +type B [5]int + +func main() { + var i interface{} + + var s1, s2 S + i = s1 == s2 + + var t1, t2 T + i = t1 == t2 + + var a1, a2 A + i = a1 == a2 + + var b1, b2 B + i = b1 == b2 + + _ = i +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug428.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug428.go new file mode 100644 index 0000000000000000000000000000000000000000..d9ad276a311ede2bc95113fceafc7c69bd1820eb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug428.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2012 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. + +// Test that when the compiler expands append inline it does not +// overwrite a value before it needs it (issue 3369). + +package main + +func main() { + s := make([]byte, 5, 6) + copy(s, "12346") + s = append(s[:len(s)-1], '5', s[len(s)-1]) + if string(s) != "123456" { + panic(s) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug430.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug430.go new file mode 100644 index 0000000000000000000000000000000000000000..93d5cf2d5bded494ad042f184aa35a3c5ea18acf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug430.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2012 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. + +// gccgo crashed compiling this. + +package main + +type S struct { + f [2][]int +} + +func F() (r [2][]int) { + return +} + +func main() { + var a []S + a[0].f = F() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug431.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug431.go new file mode 100644 index 0000000000000000000000000000000000000000..1057dadcc217130e7648b7ea8135456c53ac03e3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug431.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2012 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. + +// gccgo gave an invalid error ("floating point constant truncated to +// integer") compiling this. + +package p + +const C = 1<<63 - 1 + +func F(i int64) int64 { + return i +} + +var V = F(int64(C) / 1e6) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug432.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug432.go new file mode 100644 index 0000000000000000000000000000000000000000..0c1a9146108089318caeceae345065c8ceb8de12 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug432.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2012 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. + +// gccgo crashed compiling this. + +package p + +var v struct{ I } + +type I interface{} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug433.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug433.go new file mode 100644 index 0000000000000000000000000000000000000000..1139dfa008898291fcf085b39a5a01ed4403fa1b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug433.go @@ -0,0 +1,39 @@ +// run + +// Copyright 2012 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. + +// Test that initializing struct fields out of order still runs +// functions in the right order. This failed with gccgo. + +package main + +type S struct { + i1, i2, i3 int +} + +var G int + +func v(i int) int { + if i != G { + panic(i) + } + G = i + 1 + return G +} + +func F() S { + return S{ + i1: v(0), + i3: v(1), + i2: v(2), + } +} + +func main() { + s := F() + if s != (S{1, 3, 2}) { + panic(s) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug434.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug434.go new file mode 100644 index 0000000000000000000000000000000000000000..5abb567b43fc20433c199d170d9db342404f2acc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug434.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2012 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. + +// Test that typed and untyped negative zero floating point constants +// are treated as equivalent to zero constants. + +package main + +import "math" + +const zero = 0.0 + +func main() { + x := -zero + b := math.Float64bits(x) + if b != 0 { + panic(b) + } + x = -float64(zero) + b = math.Float64bits(x) + if b != 0 { + panic(b) + } + v := x + b = math.Float64bits(-v) + if b != 0x8000000000000000 { + panic(b) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug435.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug435.go new file mode 100644 index 0000000000000000000000000000000000000000..692a4920165ab7645057026ef983289c3fa50b36 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug435.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2012 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. + +// Test that a syntax error caused by an unexpected EOF +// gives an error message with the correct line number. +// +// https://golang.org/issue/3392 + +package main + +func foo() { + bar(1, // ERROR "unexpected|missing|undefined" \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug436.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug436.go new file mode 100644 index 0000000000000000000000000000000000000000..e848eaeba24e94caa3e6ac34feabf4eeb36eedfb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug436.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2012 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. + +// Gccgo used to crash compiling this. + +package main + +func foo() (int, int) { + return 1, 2 +} + +var c = b +var a, b = foo() +var d = b + 1 + +func main() { + if a != 1 { + panic(a) + } + if b != 2 { + panic(b) + } + if c != 2 { + panic(c) + } + if d != 3 { + panic(d) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug437.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug437.go new file mode 100644 index 0000000000000000000000000000000000000000..98adce7cb4c6ba0abd8708362e6ce87c9ee2ad61 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug437.go @@ -0,0 +1,11 @@ +// rundir + +// Copyright 2012 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. + +// Test converting a type defined in a different package to an +// interface defined in a third package, where the interface has a +// hidden method. This used to cause a link error with gccgo. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug438.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug438.go new file mode 100644 index 0000000000000000000000000000000000000000..15d3fdab8931a58604e7b157472c01668239480b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug438.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2012 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. + +// Gccgo used to incorrectly give an error when compiling this. + +package p + +func F() (i int) { + for first := true; first; first = false { + i++ + } + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug439.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug439.go new file mode 100644 index 0000000000000000000000000000000000000000..87d4ae0373a14c2fa746a5483211479a618f1207 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug439.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2012 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. + +// Gccgo used to crash compiling this. + +package p + +type E int + +func (e E) P() *E { return &e } + +const ( + C1 E = 0 + C2 = C1 +) + +func F() *E { + return C2.P() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug440_32.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug440_32.go new file mode 100644 index 0000000000000000000000000000000000000000..2d26fbb90ab80c1e18bf81dd744b98f85a8bb7a3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug440_32.go @@ -0,0 +1,21 @@ +// run + +// Test for 8g register move bug. The optimizer gets confused +// about 16- vs 32-bit moves during splitContractIndex. + +// Issue 3910. + +package main + +func main() { + const c = 0x12345678 + index, n, offset := splitContractIndex(c) + if index != int((c&0xffff)>>5) || n != int(c&(1<<5-1)) || offset != (c>>16)&(1<<14-1) { + println("BUG", index, n, offset) + } +} + +func splitContractIndex(ce uint32) (index, n, offset int) { + h := uint16(ce) + return int(h >> 5), int(h & (1<<5 - 1)), int(ce>>16) & (1<<14 - 1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug440_64.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug440_64.go new file mode 100644 index 0000000000000000000000000000000000000000..3ab3e565da00a7be6921351832cb0f88fdebea68 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug440_64.go @@ -0,0 +1,21 @@ +// run + +// Test for 6g register move bug. The optimizer gets confused +// about 32- vs 64-bit moves during splitContractIndex. + +// Issue 3918. + +package main + +func main() { + const c = 0x123400005678 + index, offset := splitContractIndex(c) + if index != (c&0xffffffff)>>5 || offset != c+1 { + println("BUG", index, offset) + } +} + +func splitContractIndex(ce uint64) (index uint32, offset uint64) { + h := uint32(ce) + return h >> 5, ce + 1 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug441.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug441.go new file mode 100644 index 0000000000000000000000000000000000000000..b67125b1e88ab789ff3bc6b6c53afe5d7cb970f1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug441.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2012 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. + +// Was discarding function calls made for arguments named _ +// in inlined functions. Issue 3593. + +package main + +var did int + +func main() { + foo(side()) + foo2(side(), side()) + foo3(side(), side()) + T.m1(T(side())) + T(1).m2(side()) + const want = 7 + if did != want { + println("BUG: missing", want-did, "calls") + } +} + +func foo(_ int) {} +func foo2(_, _ int) {} +func foo3(int, int) {} +type T int +func (_ T) m1() {} +func (t T) m2(_ int) {} + +func side() int { + did++ + return 1 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug442.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug442.go new file mode 100644 index 0000000000000000000000000000000000000000..684d54ffbbd6334ecbc158e15ffd4701b6c506c9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug442.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2012 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. + +// Used to crash generating hash and == functions for struct +// with leading _ field. Issue 3607. + +package main + +type T struct { + _ int + X interface{} + _ string + Y float64 +} + +func main() { + m := map[T]int{} + m[T{X: 1, Y: 2}] = 1 + m[T{X: 2, Y: 3}] = 2 + m[T{X: 1, Y: 2}] = 3 // overwrites first entry + if len(m) != 2 { + println("BUG") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug443.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug443.go new file mode 100644 index 0000000000000000000000000000000000000000..9abd2548a589be58dd3c910dce3a46cd2f735886 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug443.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2012 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. + +// Was failing to compile with 'invalid receiver' due to +// incomplete type definition evaluation. Issue 3709. + +package p + +type T1 struct { F *T2 } +type T2 T1 + +type T3 T2 +func (*T3) M() // was invalid receiver + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug444.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug444.go new file mode 100644 index 0000000000000000000000000000000000000000..29a60f590f06eba4ac26b70eb2ddbba4862364d4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug444.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2012 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. + +// The no-op conversion here used to confuse the compiler +// into doing a load-effective-address of nil. +// See issue 3670. + +package main + +import "reflect" + +type T interface {} + +var x bool + +func main() { + reflect.TypeOf(nil) + reflect.TypeOf(T(nil)) // used to miscompile + shouldPanic() +} + +func f() byte { + return []byte(nil)[0] // used to miscompile +} + +func shouldPanic() { + defer func() { + if recover() == nil { + panic("not panicking") + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug445.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug445.go new file mode 100644 index 0000000000000000000000000000000000000000..45c32902e58d91bf87e9b5bfcdded7d87c114719 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug445.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2012 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. + +// Issue 3765 + +package main + +func f(x uint) uint { + m := ^(1 << x) + return uint(m) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug446.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug446.go new file mode 100644 index 0000000000000000000000000000000000000000..1e435e1109ee25353d7d36c6d169fcf4fad4a405 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug446.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2012 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. + +// Issue 3824. +// Method calls are ignored when deciding initialization +// order. + +package main + +type T int + +func (r T) Method1() int { return a } +func (r T) Method2() int { return b } + +// dummy1 and dummy2 must be initialized after a and b. +var dummy1 = T(0).Method1() +var dummy2 = T.Method2(0) + +// Use a function call to force generating code. +var a = identity(1) +var b = identity(2) + +func identity(a int) int { return a } + +func main() { + if dummy1 != 1 { + panic("dummy1 != 1") + } + if dummy2 != 2 { + panic("dummy2 != 2") + } +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug447.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug447.go new file mode 100644 index 0000000000000000000000000000000000000000..8358f0034f91efd2ce1a4c27a1f4c23ed931e8e2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug447.go @@ -0,0 +1,105 @@ +// runoutput + +// Copyright 2012 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. + +// Issue 3804 +// test all possible float -> integer conversions + +package main + +import ( + "bytes" + "fmt" + "strings" +) + +var ( + intWidths = []int{8, 16, 32, 64} // int%d and uint%d + floatWidths = []int{32, 64} // float%d +) + +func main() { + + var names, funcs bytes.Buffer + + for _, iWidth := range intWidths { + for _, typ := range []string{"int", "uint"} { + var segs bytes.Buffer + itype := fmt.Sprintf("%s%d", typ, iWidth) + names.WriteString("\ttest" + itype + ",\n") + for _, fWidth := range floatWidths { + ftype := fmt.Sprintf("float%d", fWidth) + seg := strings.Replace(testSegment, "$F", ftype, -1) + seg = strings.Replace(seg, "$I", itype, -1) + segs.WriteString(seg) + } + body := strings.Replace(testFunc, "$I", itype, -1) + if typ[0] == 'u' { + body = strings.Replace(body, "$TEST", " || i < 0", 1) + } else { + body = strings.Replace(body, "$TEST", "", 1) + } + body = strings.Replace(body, "$TESTSEGMENTS", segs.String(), 1) + funcs.WriteString(body) + } + } + + program = strings.Replace(program, "$NAMES", names.String(), 1) + program = strings.Replace(program, "$FUNCS", funcs.String(), 1) + fmt.Print(program) +} + +const testSegment = ` + f$F := $F(f) + if math.Abs(float64(f$F) - f) < 0.05 { + if v := $I(f$F); v != $I(i) { + fmt.Printf("$I($F(%f)) = %v, expected %v\n", f, v, i) + } + }` + +const testFunc = +`func test$I(f float64, i int64) { + if i != int64($I(i))$TEST { + return + } +$TESTSEGMENTS +} +` + +var program = +`package main + +import ( + "fmt" + "math" +) + +var tests = []struct { + f float64 + i int64 +}{ + {39.7, 39}, + {-39.7, -39}, + {258.6, 258}, + {-258.6, -258}, + {65538.9, 65538}, + {-65538.9, -65538}, + {4294967298.8, 4294967298}, + {-4294967298.8, -4294967298}, +} + +var funcs = []func(float64, int64){ +$NAMES +} + +$FUNCS +func main() { + for _, t := range tests { + for _, f := range funcs { + f(t.f, t.i) + } + } +} +` diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug448.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug448.go new file mode 100644 index 0000000000000000000000000000000000000000..481acda3284a8f2554c4b7b91932b0e9e25568bc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug448.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2012 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug449.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug449.go new file mode 100644 index 0000000000000000000000000000000000000000..a9650f4c6f654f6d0e869104d7eecf6c68495edb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug449.go @@ -0,0 +1,69 @@ +// runoutput + +// Copyright 2012 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. + +// Issue 3866 +// runtime.equal failed to take padding between arguments and +// return values into account, so in certain cases gc-generated +// code will read a random bool from the stack as the result of +// the comparison. +// This program generates a lot of equality tests and hopes to +// catch this. +// NOTE: this program assumes comparing instance of T and T's +// underlying []byte will make gc emit calls to runtime.equal, +// and if gc optimizes this case, then the test will no longer +// be correct (in the sense that it no longer tests runtime.equal). + +package main + +import ( + "bytes" + "fmt" + "strconv" + "strings" +) + +const ntest = 1024 + +func main() { + var decls, calls bytes.Buffer + + for i := 1; i <= ntest; i++ { + s := strconv.Itoa(i) + decls.WriteString(strings.Replace(decl, "$", s, -1)) + calls.WriteString(strings.Replace("call(test$)\n\t", "$", s, -1)) + } + + program = strings.Replace(program, "$DECLS", decls.String(), 1) + program = strings.Replace(program, "$CALLS", calls.String(), 1) + fmt.Print(program) +} + +var program = `package main + +var count int + +func call(f func() bool) { + if f() { + count++ + } +} + +$DECLS + +func main() { + $CALLS + if count != 0 { + println("failed", count, "case(s)") + } +} +` + +const decl = ` +type T$ [$]uint8 +func test$() bool { + v := T${1} + return v == [$]uint8{2} || v != [$]uint8{1} +}` diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug450.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug450.go new file mode 100644 index 0000000000000000000000000000000000000000..f64063a26c289e8f35d1d071ceb22fb50876438d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug450.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2012 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. + +// Issue 3899: 8g incorrectly thinks a variable is +// "set and not used" and elides an assignment, causing +// variables to end up with wrong data. +// +// The reason is a miscalculation of variable width. + +package main + +func bar(f func()) { + f() +} + +func foo() { + f := func() {} + if f == nil { + } + bar(f) +} + +func main() { + foo() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug451.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug451.go new file mode 100644 index 0000000000000000000000000000000000000000..75ce97490ec7efaad819b08feb6b006f6360e8b7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug451.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2012 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 + +type T x.T // ERROR "undefined|expected package" + +// bogus "invalid recursive type" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug452.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug452.go new file mode 100644 index 0000000000000000000000000000000000000000..f1f8b08e63b2f72fc1cafd39844c7ac7fd87c671 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug452.go @@ -0,0 +1,38 @@ +// run + +// Copyright 2012 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. + +// Issue 3835: 8g tries to optimize arithmetic involving integer +// constants, but can run out of registers in the process. + +package main + +var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, A, B, C, D, E, F, G int + +func foo() int { + return a + 1 + b + 2 + c + 3 + d + 4 + e + 5 + f + 6 + g + 7 + h + 8 + i + 9 + j + 10 + + k + 1 + l + 2 + m + 3 + n + 4 + o + 5 + p + 6 + q + 7 + r + 8 + s + 9 + t + 10 + + u + 1 + v + 2 + w + 3 + x + 4 + y + 5 + z + 6 + A + 7 + B + 8 + C + 9 + D + 10 + + E + 1 + F + 2 + G + 3 +} + +func bar() int8 { + var ( + W int16 + X int32 + Y int32 + Z int32 + ) + return int8(W+int16(X+3)+3) * int8(Y+3+Z*3) +} + +func main() { + if foo() == 0 { + panic("foo") + } + if bar() == 0 { + panic("bar") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug453.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug453.go new file mode 100644 index 0000000000000000000000000000000000000000..1f4f3ea9bd89f2fe13047e31e4813b9448224110 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug453.go @@ -0,0 +1,39 @@ +// run + +// Copyright 2012 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. + +// Issue 4138: bug in floating-point registers numbering. +// Makes 6g unable to use more than 11 registers. + +package main + +func formula() float32 { + mA := [1]float32{1.0} + det1 := mA[0] + det2 := mA[0] + det3 := mA[0] + det4 := mA[0] + det5 := mA[0] + det6 := mA[0] + det7 := mA[0] + det8 := mA[0] + det9 := mA[0] + det10 := mA[0] + det11 := mA[0] + det12 := mA[0] + + return det1 + det2*det3 + + det4*det5 + det6*det7 + + det8*det9 + det10*det11 + + det12 +} + +func main() { + x := formula() + if x != 7.0 { + println(x, 7.0) + panic("x != 7.0") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug454.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug454.go new file mode 100644 index 0000000000000000000000000000000000000000..9e3344d5124a60d720b6ada349a6dbc5372c370f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug454.go @@ -0,0 +1,21 @@ +// run + +// Copyright 2012 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. + +// Issue 4173 + +package main + +func main() { + var arr *[10]int + s := 0 + for i, _ := range arr { + // used to panic trying to access arr[i] + s += i + } + if s != 45 { + println("BUG") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug455.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug455.go new file mode 100644 index 0000000000000000000000000000000000000000..9f6974d0643d3612eb16dc536f0743f0e8254dec --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug455.go @@ -0,0 +1,54 @@ +// run + +// Copyright 2012 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. + +// Issue 4156: out of fixed registers when chaining method calls. +// Used to happen with 6g. + +package main + +type test_i interface { + Test() test_i + Result() bool +} + +type test_t struct { +} + +func newTest() *test_t { + return &test_t{} +} + +type testFn func(string) testFn + +func main() { + test := newTest() + + switch { + case test. + Test(). + Test(). + Test(). + Test(). + Test(). + Test(). + Test(). + Test(). + Test(). + Test(). + Result(): + // case worked + default: + panic("Result returned false unexpectedly") + } +} + +func (t *test_t) Test() test_i { + return t +} + +func (t *test_t) Result() bool { + return true +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug456.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug456.go new file mode 100644 index 0000000000000000000000000000000000000000..c77a76d057ac512617f504f73a8e069779dbf57e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug456.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2012 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. + +// Issue 3907: out of fixed registers in nested byte multiply. +// Used to happen with both 6g and 8g. + +package main + +func F(a, b, c, d uint8) uint8 { + return a * (b * (c * (d * + (a * (b * (c * (d * + (a * (b * (c * (d * + a * (b * (c * d))))))))))))) +} + +func main() { + var a, b, c, d uint8 = 1, 1, 1, 1 + x := F(a, b, c, d) + if x != 1 { + println(x) + panic("x != 1") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug457.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug457.go new file mode 100644 index 0000000000000000000000000000000000000000..84f8db456622910631994f1c41e2bf7c442582e8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug457.go @@ -0,0 +1,15 @@ +// run + +// Copyright 2012 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. + +// Issue 4197: growing a slice of zero-width elements +// panics on a division by zero. + +package main + +func main() { + var x []struct{} + x = append(x, struct{}{}) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug458.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug458.go new file mode 100644 index 0000000000000000000000000000000000000000..6332697bd23dc1fac6463fc5eeda4ba52de01903 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug458.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2012 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. + +// Issue 4200: 6g crashes when a type is larger than 4GB. + +package main + +import "unsafe" + +// N=16 on 32-bit arches, 256 on 64-bit arches. +// On 32-bit arches we don't want to test types +// that are over 4GB large. +const N = 1 << unsafe.Sizeof(uintptr(0)) + +type T [N][10][10][10][10][3]byte + +func F(t *T) byte { + return t[0][0][0][0][0][0] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug459.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug459.go new file mode 100644 index 0000000000000000000000000000000000000000..a404d218e09b6cdf2947a6299e0d4f273e6991b8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug459.go @@ -0,0 +1,35 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 3890: missing detection of init cycle involving +// method calls in function bodies. + +package flag + +var commandLine = NewFlagSet() // ERROR "initialization cycle|depends upon itself" + +type FlagSet struct { +} + +func (f *FlagSet) failf(format string, a ...interface{}) { + f.usage() +} + +func (f *FlagSet) usage() { + if f == commandLine { + panic(3) + } +} + +func NewFlagSet() *FlagSet { + f := &FlagSet{} + f.setErrorHandling(true) + return f +} + +func (f *FlagSet) setErrorHandling(b bool) { + f.failf("DIE") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug460.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug460.go new file mode 100644 index 0000000000000000000000000000000000000000..a1b6f477ffd6964a5f7b18d81cab31e96a178496 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug460.go @@ -0,0 +1,10 @@ +// errorcheckdir + +// Copyright 2012 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. + +// part one of issue 4124. Make sure that the compiler rejects access attempts. + +package ignored + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug461.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug461.go new file mode 100644 index 0000000000000000000000000000000000000000..d7fe8026e8d511994d64692cb5f6fa09f81ec404 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug461.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2012 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. + +// part two of issue 4124. Make sure reflect doesn't mark the field as exported. + +package main + +import "reflect" + +var T struct { + int +} + +func main() { + v := reflect.ValueOf(&T) + v = v.Elem().Field(0) + if v.CanSet() { + panic("int should be unexported") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug462.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug462.go new file mode 100644 index 0000000000000000000000000000000000000000..c6962e48c11043bd1ae159a0731d8441ed456543 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug462.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2012 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 + +import "os" + +var _ = os.Open // avoid imported and not used error + +type T struct { + File int +} + +func main() { + _ = T{ + os.File: 1, // ERROR "invalid field name os.File|unknown field" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug463.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug463.go new file mode 100644 index 0000000000000000000000000000000000000000..36515f8961c747cf933398684d58f2b1122db138 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug463.go @@ -0,0 +1,22 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 3757: unhelpful typechecking loop message +// for constants that refer to themselves. + +package main + +const a = a // ERROR "refers to itself|definition loop|initialization cycle" + +const ( + X = A + A = B // ERROR "refers to itself|definition loop|initialization cycle" + B = D + C, D = 1, A +) + +func main() { +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug464.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug464.go new file mode 100644 index 0000000000000000000000000000000000000000..3e2c18a822c0d53bec659553dec10305b1395672 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug464.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 3937: unhelpful typechecking loop message +// for identifiers wrongly used as types. + +package main + +func foo(x foo) {} // ERROR "expected type|not a type" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug465.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug465.go new file mode 100644 index 0000000000000000000000000000000000000000..84ff07b9487534902e530ed22a3d9494128ce2a1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug465.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2012 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. + +// Issue 4230: inlining bug for composite literal in +// if, for, switch statements. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug466.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug466.go new file mode 100644 index 0000000000000000000000000000000000000000..dc909d483cdf45a69db3621767ddc7701e56d451 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug466.go @@ -0,0 +1,11 @@ +// rundir + +// Copyright 2012 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. + +// Issue 4159: exported inlinable functions squash +// complex literals "a+bi" to "a+b". + +package ignored + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug467.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug467.go new file mode 100644 index 0000000000000000000000000000000000000000..4126f92eae597fdb3da8f1067687268eaeee0afd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug467.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2012 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. + +// Exported data for inlining could forget types of +// local variables declared in inlinable bodies. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug468.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug468.go new file mode 100644 index 0000000000000000000000000000000000000000..77941ce55ce02f3ab249505f7397ae3573ff0ca9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug468.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2012 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. + +// The reflect package was not correctly checking field names +// when checking for struct assignability. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug470.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug470.go new file mode 100644 index 0000000000000000000000000000000000000000..c21663f3f312c4a52e3e2ef39c1c5e664929d0ef --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug470.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2012 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. + +// Converting constants between types must introduce rounding. + +package main + +import "fmt" + +const ( + F32 = 0.00999999977648258209228515625 + F64 = 0.01000000000000000020816681711721685132943093776702880859375 +) + +var F = float64(float32(0.01)) + +func main() { + // 0.01 rounded to float32 then to float64 is F32. + // 0.01 represented directly in float64 is F64. + if F != F32 { + panic(fmt.Sprintf("F=%.1000g, want %.1000g", F, F32)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug471.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug471.go new file mode 100644 index 0000000000000000000000000000000000000000..343661f08d5b53c0d5ad0a812488560d9d493718 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug471.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2012 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. + +// Caused an internal compiler error in gccgo. + +package p + +type C chan struct{} + +func (c C) F() { + select { + case c <- struct{}{}: + default: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug472.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug472.go new file mode 100644 index 0000000000000000000000000000000000000000..6939e641ceb3181054c9cf00fc9dbb6b35dc264e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug472.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2013 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. + +// Linker would incorrectly parse export data and think +// definitions are inconsistent. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug473.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug473.go new file mode 100644 index 0000000000000000000000000000000000000000..7649b6b5e008cc29c5498c38a32d05822ef080ae --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug473.go @@ -0,0 +1,69 @@ +// run + +// Copyright 2013 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. + +// Used to be miscompiled by gccgo, due to a bug in handling +// initialization ordering. + +package main + +func F(a ...interface{}) interface{} { + s := 0 + for _, v := range a { + s += v.(int) + } + return s +} + +var V1 = F(V10, V4, V3, V11) + +var V2 = F(V1) + +var V3 = F(1) + +var V4 = F(2) + +var V5 = F(3) + +var V6 = F(4) + +var V7 = F(5) + +var V8 = F(V14, V7, V3, V6, V5) + +var V9 = F(V4, F(V12)) + +var V10 = F(V4, V9) + +var V11 = F(6) + +var V12 = F(V5, V3, V8) + +var V13 = F(7) + +var V14 = F(8) + +func expect(name string, a interface{}, b int) { + if a.(int) != b { + panic(name) + } +} + +func main() { + expect("V1", V1, 38) + expect("V2", V2, 38) + expect("V3", V3, 1) + expect("V4", V4, 2) + expect("V5", V5, 3) + expect("V6", V6, 4) + expect("V7", V7, 5) + expect("V8", V8, 21) + expect("V9", V9, 27) + expect("V10", V10, 29) + expect("V11", V11, 6) + expect("V12", V12, 25) + expect("V13", V13, 7) + expect("V14", V14, 8) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug474.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug474.go new file mode 100644 index 0000000000000000000000000000000000000000..1efabe460a68036a9b740bea2aab0e4e24d003f2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug474.go @@ -0,0 +1,29 @@ +// run + +// Copyright 2013 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. + +// Bug in method values: escape analysis was off. + +package main + +import "sync" + +var called = false + +type T struct { + once sync.Once +} + +func (t *T) M() { + called = true +} + +func main() { + var t T + t.once.Do(t.M) + if !called { + panic("not called") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug475.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug475.go new file mode 100644 index 0000000000000000000000000000000000000000..0145aabf4117de045e86b07a85c3d7b1810cbb59 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug475.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2013 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. + +// Variable in enclosing function with same name as field in struct +// composite literal confused gccgo. + +package p + +type s1 struct { + f *s1 +} + +func F() { + var f *s1 + _ = func() { + _ = s1{f: nil} + } + _ = f +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug476.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug476.go new file mode 100644 index 0000000000000000000000000000000000000000..8695f95c42fe5d0f40898159ee224e35d251a8da --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug476.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2013 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. + +// Logical operation on named boolean type returns the same type, +// supporting an implicit conversion to an interface type. This used +// to crash gccgo. + +package p + +type B bool + +func (b B) M() {} + +type I interface { + M() +} + +func F(a, b B) I { + return a && b +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug477.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug477.go new file mode 100644 index 0000000000000000000000000000000000000000..f1fbffa211881279dda70229ab849d41765f15b3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug477.go @@ -0,0 +1,34 @@ +// compile + +// Copyright 2013 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. + +// Test multiple identical unnamed structs with methods. This caused +// a compilation error with gccgo. + +package p + +type S1 struct{} + +func (s S1) M() {} + +type S2 struct { + F1 struct { + S1 + } + F2 struct { + S1 + } +} + +type I interface { + M() +} + +func F() { + var s2 S2 + var i1 I = s2.F1 + var i2 I = s2.F2 + _, _ = i1, i2 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug478.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug478.go new file mode 100644 index 0000000000000000000000000000000000000000..8757f461532a2d6223845820ac36bb2df31b71ea --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug478.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2013 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. + +// Using the same unexported name for a method as a method on an +// imported embedded type caused a gccgo compilation failure. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug479.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug479.go new file mode 100644 index 0000000000000000000000000000000000000000..80012ba8e467b3d5bb4d19a5c5a9af872dd169dc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug479.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2013 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. + +// Gccgo was not consistent in deciding how to compare a struct type +// for equality, leading to an undefined symbol at link time. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug480.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug480.go new file mode 100644 index 0000000000000000000000000000000000000000..ad2f73c16b9399a20ebd356b8d8043a02ebc487a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug480.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2013 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. + +// Gccgo mishandled an import of a forward declared type. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug481.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug481.go new file mode 100644 index 0000000000000000000000000000000000000000..13a53392da5cd1e61f026f3d0851b3607d6a0f6f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug481.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2013 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. + +// Returning an index into a conversion from string to slice caused a +// compilation error when using gccgo. + +package p + +func F1(s string) byte { + return []byte(s)[0] +} + +func F2(s string) rune { + return []rune(s)[0] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug482.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug482.go new file mode 100644 index 0000000000000000000000000000000000000000..0e5417dee7550b9d6a8c4fe3338789e9f3c27f68 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug482.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2013 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. + +// Using the same name for a field in a composite literal and for a +// global variable that depends on the variable being initialized +// caused gccgo to erroneously report "variable initializer refers to +// itself". + +package p + +type S struct { + F int +} + +var V = S{F: 1} + +var F = V.F diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug483.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug483.go new file mode 100644 index 0000000000000000000000000000000000000000..8db6425be69d1c391c8448ab07eb250ca9ea3fb7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug483.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2014 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. + +// Test for a garbage collection bug involving not +// marking x as having its address taken by &x[0] +// when x is an array value. + +package main + +import ( + "bytes" + "fmt" + "runtime" +) + +func main() { + var x = [4]struct{ x, y interface{} }{ + {"a", "b"}, + {"c", "d"}, + {"e", "f"}, + {"g", "h"}, + } + + var buf bytes.Buffer + for _, z := range x { + runtime.GC() + fmt.Fprintf(&buf, "%s %s ", z.x.(string), z.y.(string)) + } + + if buf.String() != "a b c d e f g h " { + println("BUG wrong output\n", buf.String()) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug484.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug484.go new file mode 100644 index 0000000000000000000000000000000000000000..bd4fa516a235dbf5d49638f08ddb156fd42eb88c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug484.go @@ -0,0 +1,78 @@ +// run + +// Copyright 2014 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. + +// The liveness code used to say that, in func g, s was live +// starting at its declaration, because it appears to have its +// address taken by the closure (different s, but the parser +// gets slightly confused, a separate bug). The liveness analysis +// saw s as having its address taken but the register optimizer +// did not. This mismatch meant that s would be marked live +// (and therefore initialized) at the call to f, but the register optimizer +// would optimize away the initialization of s before f, causing the +// garbage collector to use unused data. +// The register optimizer has been changed to respect the +// same "address taken" flag that the liveness analysis uses, +// even if it cannot see any address being taken in the actual +// machine code. This is conservative but keeps the two consistent, +// which is the most important thing. + +package main + +import "runtime" + +//go:noinline +func f() interface{} { + runtime.GC() + return nil +} + +//go:noinline +func g() { + var s interface{} + _ = func() { + s := f() + _ = s + } + s = f() + useiface(s) + useiface(s) +} + +//go:noinline +func useiface(x interface{}) { +} + +//go:noinline +func h() { + var x [16]uintptr + for i := range x { + x[i] = 1 + } + + useint(x[0]) + useint(x[1]) + useint(x[2]) + useint(x[3]) +} + +//go:noinline +func useint(x uintptr) { +} + +func main() { + // scribble non-zero values on stack + h() + // call function that used to let the garbage collector + // see uninitialized stack values; it will see the + // nonzero values. + g() +} + +func big(x int) { + if x >= 0 { + big(x - 1) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug485.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug485.go new file mode 100644 index 0000000000000000000000000000000000000000..c99faed43e427d4eb800f5a3c870530c52afb944 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug485.go @@ -0,0 +1,39 @@ +// run + +// Copyright 2014 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. + +// Gccgo chose the wrong embedded method when the same type appeared +// at different levels and the correct choice was not the first +// appearance of the type in a depth-first search. + +package main + +type embedded string + +func (s embedded) val() string { + return string(s) +} + +type A struct { + embedded +} + +type B struct { + A + embedded +} + +func main() { + b := &B{ + A: A{ + embedded: "a", + }, + embedded: "b", + } + s := b.val() + if s != "b" { + panic(s) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug486.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug486.go new file mode 100644 index 0000000000000000000000000000000000000000..9ad23b3cfcb7d68a8a8d243d29cafc793848b9a2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug486.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2014 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. + +// The gccgo lexer had a bug handling nested comments. +// http://gcc.gnu.org/PR61746 +// http://code.google.com/p/gofrontend/issues/detail?id=35 + +package main + +/*// comment +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug487.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug487.go new file mode 100644 index 0000000000000000000000000000000000000000..150d660abc20e6e552f2f175146a12287b3f7b1b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug487.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2014 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. + +// The gccgo compiler did not reliably report mismatches between the +// number of function results and the number of expected results. + +package p + +func G() (int, int, int) { + return 0, 0, 0 +} + +func F() { + a, b := G() // ERROR "mismatch|cannot initialize" + a, b = G() // ERROR "mismatch|cannot assign" + _, _ = a, b +} + +func H() (int, int) { + return G() // ERROR "too many|mismatch|wrong number" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug488.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug488.go new file mode 100644 index 0000000000000000000000000000000000000000..3912debac9ccb85fac486dbfa6c9c27a35454e78 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug488.go @@ -0,0 +1,12 @@ +// errorcheckdir + +// Copyright 2014 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. + +// The gccgo compiler had a bug: if one file in a package did a dot +// import, then an earlier file in the package would incorrectly +// resolve to the imported names rather than reporting undefined +// errors. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug489.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug489.go new file mode 100644 index 0000000000000000000000000000000000000000..34250cd8795ae1352d01fa7ba5bb77c7a3f6564b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug489.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2014 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. + +// The gccgo compiler had a bug: mentioning a function type in an +// expression in a function literal messed up the list of variables +// referenced in enclosing functions. + +package main + +func main() { + v1, v2 := 0, 0 + f := func() { + a := v1 + g := (func())(nil) + b := v2 + _, _, _ = a, g, b + } + _, _, _ = v1, v2, f +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug490.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug490.go new file mode 100644 index 0000000000000000000000000000000000000000..387a680aeefdf86489b4ca2e891927144b23ba1c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug490.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2014 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. + +// The gccgo compiler used to crash building a comparison between an +// interface and an empty struct literal. + +package p + +type S struct{} + +func F(v interface{}) bool { + return v == S{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug491.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug491.go new file mode 100644 index 0000000000000000000000000000000000000000..39a3509c69e321640e0064870ec8ac4c105689a6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug491.go @@ -0,0 +1,110 @@ +// run + +// Copyright 2014 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. + +// Test order of calls to builtin functions. +// Discovered during CL 144530045 review. + +package main + +func main() { + // append + { + x := make([]int, 0) + f := func() int { x = make([]int, 2); return 2 } + a, b, c := append(x, 1), f(), append(x, 1) + if len(a) != 1 || len(c) != 3 { + bug() + println("append call not ordered:", len(a), b, len(c)) + } + } + + // cap + { + x := make([]int, 1) + f := func() int { x = make([]int, 3); return 2 } + a, b, c := cap(x), f(), cap(x) + if a != 1 || c != 3 { + bug() + println("cap call not ordered:", a, b, c) + } + } + + // complex + { + x := 1.0 + f := func() int { x = 3; return 2 } + a, b, c := complex(x, 0), f(), complex(x, 0) + if real(a) != 1 || real(c) != 3 { + bug() + println("complex call not ordered:", a, b, c) + } + } + + // copy + { + tmp := make([]int, 100) + x := make([]int, 1) + f := func() int { x = make([]int, 3); return 2 } + a, b, c := copy(tmp, x), f(), copy(tmp, x) + if a != 1 || c != 3 { + bug() + println("copy call not ordered:", a, b, c) + } + } + + // imag + { + x := 1i + f := func() int { x = 3i; return 2 } + a, b, c := imag(x), f(), imag(x) + if a != 1 || c != 3 { + bug() + println("imag call not ordered:", a, b, c) + } + } + + // len + { + x := make([]int, 1) + f := func() int { x = make([]int, 3); return 2 } + a, b, c := len(x), f(), len(x) + if a != 1 || c != 3 { + bug() + println("len call not ordered:", a, b, c) + } + } + + // make + { + x := 1 + f := func() int { x = 3; return 2 } + a, b, c := make([]int, x), f(), make([]int, x) + if len(a) != 1 || len(c) != 3 { + bug() + println("make call not ordered:", len(a), b, len(c)) + } + } + + // real + { + x := 1 + 0i + f := func() int { x = 3; return 2 } + a, b, c := real(x), f(), real(x) + if a != 1 || c != 3 { + bug() + println("real call not ordered:", a, b, c) + } + } +} + +var bugged = false + +func bug() { + if !bugged { + println("BUG") + bugged = true + } +} \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug492.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug492.go new file mode 100644 index 0000000000000000000000000000000000000000..050a9e5ee203e470c9b7a9c9a26ae4dd9440988e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug492.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2014 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. + +// Test case that gccgo failed to link. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug493.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug493.go new file mode 100644 index 0000000000000000000000000000000000000000..643e9af4b8ea79b42267d8dd8b9f534e6000157f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug493.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2014 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. + +// Test case that gccgo failed to compile. + +package p + +func F() []string { + return []string{""} +} + +var V = append(F()) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug494.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug494.go new file mode 100644 index 0000000000000000000000000000000000000000..42f18797f78cb6191e81ca79bae00b2bc4913e27 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug494.go @@ -0,0 +1,51 @@ +// run + +// Copyright 2014 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. + +// Gccgo incorrectly executed functions multiple times when they +// appeared in a composite literal that required a conversion between +// different interface types. + +package main + +type MyInt int + +var c MyInt + +func (c *MyInt) S(i int) { + *c = MyInt(i) +} + +func (c *MyInt) V() int { + return int(*c) +} + +type i1 interface { + S(int) + V() int +} + +type i2 interface { + V() int +} + +type s struct { + i i2 +} + +func f() i1 { + c++ + return &c +} + +func main() { + p := &s{f()} + if v := p.i.V(); v != 1 { + panic(v) + } + if c != 1 { + panic(c) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug495.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug495.go new file mode 100644 index 0000000000000000000000000000000000000000..dfc0c9f803f66e253708126d41d224916f0f8310 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug495.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2015 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. + +// Gccgo used to give an incorrect error +// bug495.go:16:2: error: missing statement after label + +package p + +func F(i int) { + switch i { + case 0: + goto lab + lab: + fallthrough + case 1: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug496.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug496.go new file mode 100644 index 0000000000000000000000000000000000000000..4307c75e83a69b0785af1f08dd8b5408c2f97693 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug496.go @@ -0,0 +1,29 @@ +// compile + +// Copyright 2015 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. + +// Gccgo used to give an error: +// : error: redefinition of ‘s$F$hash’ +// : note: previous definition of ‘s$F$hash’ was here +// : error: redefinition of ‘s$F$equal’ +// : note: previous definition of ‘s$F$equal’ was here + +package p + +type T1 int + +func (t T1) F() { + type s struct { + f string + } +} + +type T2 int + +func (t T2) F() { + type s struct { + f string + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug497.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug497.go new file mode 100644 index 0000000000000000000000000000000000000000..7081b1cb3567f59103f649c970539a708c49e31b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug497.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2015 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. + +// Gccgo used to miscompile passing a global variable with a +// zero-sized type to a function. + +package main + +type T struct { + field s +} + +type s struct{} + +var X T + +func F(_ T, c interface{}) int { + return len(c.(string)) +} + +func main() { + if v := F(X, "hi"); v != 2 { + panic(v) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug498.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug498.go new file mode 100644 index 0000000000000000000000000000000000000000..91b5c2f6885e1af6c190cfdf7804bebf8a468c86 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug498.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2016 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. + +// Gccgo incorrectly rejected an assignment to multiple instances of +// the same variable. + +package main + +var a int + +func F() { + a, a, a = 1, 2, 3 +} + +func main() { + F() + if a != 3 { + panic(a) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug499.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug499.go new file mode 100644 index 0000000000000000000000000000000000000000..e4142e935bd131902760b7f178fccd523e8ef5b1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug499.go @@ -0,0 +1,15 @@ +// run + +// Copyright 2016 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. + +// Gccgo got confused when a type was used both for a map bucket type +// and for a map key type. + +package main + +func main() { + _ = make(map[byte]byte) + _ = make(map[[8]byte]chan struct{}) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug500.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug500.go new file mode 100644 index 0000000000000000000000000000000000000000..2dd5df13b0c5a92d75fc923ceeded2cbc3b44583 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug500.go @@ -0,0 +1,41 @@ +// run + +// Copyright 2016 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. + +// Gccgo generated incorrect GC info when a global variable was +// initialized to a slice of a value containing pointers. The initial +// backing array for the slice was allocated in the .data section, +// which is fine, but the backing array was not registered as a GC +// root. + +package main + +import ( + "runtime" +) + +type s struct { + str string +} + +var a = []struct { + str string +}{ + {""}, +} + +var b = "b" +var c = "c" + +func init() { + a[0].str = b + c +} + +func main() { + runtime.GC() + if a[0].str != b + c { + panic(a[0].str) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug501.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug501.go new file mode 100644 index 0000000000000000000000000000000000000000..8e951b18c8e2a91885c99c4d86c6035cc4ab3dfb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug501.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2016 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. + +// Gccgo got a compiler crash compiling the addition of more than five +// strings with mixed constants and variables. + +package main + +func F(s string) (string, error) { + return s, nil +} + +func G(a, b, c string) (string, error) { + return F("a" + a + "b" + b + "c" + c) +} + +func main() { + if got, _ := G("x", "y", "z"); got != "axbycz" { + panic(got) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug502.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug502.go new file mode 100644 index 0000000000000000000000000000000000000000..cff73e7d7fe0b238c49859c7eafb1ea7fa85ec81 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug502.go @@ -0,0 +1,28 @@ +// build + +// Copyright 2017 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. + +// Linking this with gccgo got an undefined symbol reference, +// because the private method in testing.TB led gccgo to assume that +// the interface method table would be defined in the testing package. + +package main + +import "testing" + +type I interface { + testing.TB + Parallel() +} + +func F(i I) { + i.Log("F") +} + +var t testing.T + +func main() { + F(&t) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug503.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug503.go new file mode 100644 index 0000000000000000000000000000000000000000..7bbc7981c5e8684c8689c83c840d65f748556c84 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug503.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2017 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. + +// gccgo crashed compiling this file, due to failing to correctly emit +// the type descriptor for a named alias. + +package p + +type entry = struct { + a, b, c int +} + +var V entry diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug504.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug504.go new file mode 100644 index 0000000000000000000000000000000000000000..ae1f2e52d8e0eeb6b26fd16e27cf7c68b96f2b0e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug504.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2017 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. + +// Gccgo mishandled a reference to a type alias in a package that was +// not directly imported. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug505.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug505.go new file mode 100644 index 0000000000000000000000000000000000000000..062a0871688e1f8c5b3ba186a02c4dff86c3840c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug505.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2017 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. + +// gccgo crashed compiling this file with a failed conversion to the +// alias type when constructing the composite literal. + +package p + +type I interface{ M() } +type A = I +type S struct { + f A +} + +func F(i I) S { + return S{f: i} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug506.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug506.go new file mode 100644 index 0000000000000000000000000000000000000000..7c8ccc6ec7ed7a2b36e3916f5927a6b3bc98f005 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug506.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2018 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. + +// Gccgo caused an undefined symbol reference building hash functions +// for an imported struct with unexported fields. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug507.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug507.go new file mode 100644 index 0000000000000000000000000000000000000000..2d7aa5973241dd7138dd54bec67ae9501810ab9c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug507.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2020 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. + +// Gccgo mishandled a combination of normal import and dot import. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug508.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug508.go new file mode 100644 index 0000000000000000000000000000000000000000..69b1adaf9598cf7e9df524a90068c28564ef2688 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug508.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2020 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. + +// Gccgo mishandles composite literals of map with type bool. + +package p + +var M = map[bool]uint8{ + false: 0, + true: 1, +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug509.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug509.go new file mode 100644 index 0000000000000000000000000000000000000000..df6ed61f89363dc893f9aa5ebba1918e039afcde --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug509.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2020 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. + +// Gccgo mishandles a couple of alias cases. + +package p + +type S struct{} + +func (*S) M() {} + +type I interface { + M() +} + +type A = *S + +var V1 I +var _ = V1.(*S) +var _ = V1.(A) + +func F() { + var v I + v = (*S)(nil) + v = A(nil) + _ = v +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug510.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug510.go new file mode 100644 index 0000000000000000000000000000000000000000..8a6da5dfd6a35ba685863a482eb0e0e030a7c3eb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug510.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2020 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. + +// Gccgo confused type descriptors for aliases. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug511.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug511.go new file mode 100644 index 0000000000000000000000000000000000000000..edd3a235214c77646790a3cc9ff949a6340a4f69 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug511.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2021 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. + +// Gccgo mishandled type aliases as receiver types. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug512.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug512.go new file mode 100644 index 0000000000000000000000000000000000000000..6be6eb98fe4c019ab761cfb9614343295e7cac1a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug512.go @@ -0,0 +1,52 @@ +// run + +// Copyright 2021 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. + +// Gccgo did not make a copy of a value receiver when using a +// goroutine to call a method. + +package main + +import ( + "sync" + "sync/atomic" +) + +var wg sync.WaitGroup + +type S struct { + i1, i2 int32 +} + +var done int32 + +func (s S) Check(v1, v2 int32) { + for { + if g1 := atomic.LoadInt32(&s.i1); v1 != g1 { + panic(g1) + } + if g2 := atomic.LoadInt32(&s.i2); v2 != g2 { + panic(g2) + } + if atomic.LoadInt32(&done) != 0 { + break + } + } + wg.Done() +} + +func F() { + s := S{1, 2} + go s.Check(1, 2) + atomic.StoreInt32(&s.i1, 3) + atomic.StoreInt32(&s.i2, 4) + atomic.StoreInt32(&done, 1) +} + +func main() { + wg.Add(1) + F() + wg.Wait() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug513.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug513.go new file mode 100644 index 0000000000000000000000000000000000000000..ce7ebf9b4ebb1a8d18b84eba12edfede7580e082 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug513.go @@ -0,0 +1,21 @@ +// run -race -gcflags=all=-d=checkptr=0 + +//go:build ((linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64)) && cgo + +// Copyright 2021 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. + +// Although -race turns on -d=checkptr, the explicit -d=checkptr=0 +// should override it. + +package main + +import "unsafe" + +var v1 = new([2]int16) +var v2 *[3]int64 + +func main() { + v2 = (*[3]int64)(unsafe.Pointer(uintptr(unsafe.Pointer(&(*v1)[0])))) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug514.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug514.go new file mode 100644 index 0000000000000000000000000000000000000000..9b2318533782588ed1cc9ea3b764615e2819c2b6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug514.go @@ -0,0 +1,59 @@ +// run + +// Copyright 2021 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. + +//go:build cgo + +package main + +import "runtime/cgo" + +type iface interface { + Get() int +} + +type notInHeap struct { + _ cgo.Incomplete + i int +} + +type myInt struct { + f *notInHeap +} + +func (mi myInt) Get() int { + return int(mi.f.i) +} + +type embed struct { + *myInt +} + +var val = 1234 + +var valNotInHeap = notInHeap{i: val} + +func main() { + i := val + check(i) + mi := myInt{f: &valNotInHeap} + check(mi.Get()) + ifv := iface(mi) + check(ifv.Get()) + ifv = iface(&mi) + check(ifv.Get()) + em := embed{&mi} + check(em.Get()) + ifv = em + check(ifv.Get()) + ifv = &em + check(ifv.Get()) +} + +func check(v int) { + if v != val { + panic(v) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug515.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug515.go new file mode 100644 index 0000000000000000000000000000000000000000..80d426fd6761569454429a4a08014d5f9530e5f8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug515.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2022 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. + +// Caused a gofrontend crash. + +//go:build gccgo + +package p + +//go:notinheap +type S1 struct{} + +type S2 struct { + r interface{ Read([]byte) (int, error) } + s1, s2 []byte + p *S1 + n uintptr +} + +var V any = S2{} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug516.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug516.go new file mode 100644 index 0000000000000000000000000000000000000000..e52eb215eff83755d77ec4d540ad0174c0864038 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug516.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2023 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. + +// Caused a gofrontend crash. + +package p + +func F(b []byte, i int) { + *(*[1]byte)(b[i*2:]) = [1]byte{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug517.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug517.go new file mode 100644 index 0000000000000000000000000000000000000000..00860dc4d3b43a6f2b2bddf7ec69a4942a0d9eef --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug517.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2023 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. + +// The gofrontend used to mishandle this code due to a pass ordering issue. +// It was inconsistent as to whether unsafe.Sizeof(byte(0)) was a constant, +// and therefore as to whether it was a direct-iface type. + +package main + +import "unsafe" + +type A [unsafe.Sizeof(byte(0))]*byte + +func (r A) V() byte { + return *r[0] +} + +func F() byte { + panic("F") // should never be called +} + +type B [unsafe.Sizeof(F())]*byte + +func (r B) V() byte { + return *r[0] +} + +func main() { + b := byte(1) + v := A{&b}.V() + B{&b}.V() + if v != 2 { + panic(v) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/bug518.go b/platform/dbops/binaries/go/go/test/fixedbugs/bug518.go new file mode 100644 index 0000000000000000000000000000000000000000..c3ec1f4df4f5d6067bf78d4bca02fd9e4e844097 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/bug518.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2023 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. + +// The gofrontend used to accept this. + +package p + +func F2(a int32) bool { + return a == C // ERROR "invalid|incompatible" +} + +const C = uint32(34) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc101994.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc101994.go new file mode 100644 index 0000000000000000000000000000000000000000..6e1e2b8075181217dcc7ed5859e370bbf04695cf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc101994.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2021 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. + +// https://gcc.gnu.org/PR101994 +// gccgo compiler crash with zero-sized result. + +package p + +type Empty struct{} + +func F() (int, Empty) { + return 0, Empty{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61204.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61204.go new file mode 100644 index 0000000000000000000000000000000000000000..e175f83633919ab8a5f28611c6bdab6b9062922f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61204.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2014 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. + +// PR61204: Making temporaries for zero-sized types caused an ICE in gccgo. +// This is a reduction of a program reported by GoSmith. + +package main + +func main() { + type t [0]int + var v t + v, _ = [0]int{}, 0 + _ = v +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61244.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61244.go new file mode 100644 index 0000000000000000000000000000000000000000..642bc610bbf7e7d37727d4425190366fb0101fbb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61244.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2014 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. + +// PR61244: Type descriptors expressions were not traversed, causing an ICE +// in gccgo when producing the backend representation. +// This is a reduction of a program reported by GoSmith. + +package main + +const a = 0 + +func main() { + switch i := (interface{})(a); i.(type) { + case [0]string: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61246.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61246.go new file mode 100644 index 0000000000000000000000000000000000000000..797d6c7ffca829178c0bb6d0ed6c11d2e113a7a8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61246.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2014 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. + +// PR61246: Switch conditions could be untyped, causing an ICE when the +// conditions were lowered into temporaries. +// This is a reduction of a program reported by GoSmith. + +package main + +func main() { + switch 1 != 1 { + default: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61248.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61248.go new file mode 100644 index 0000000000000000000000000000000000000000..cb59c9fa7c85c5cf13c9308952e731db752f3e16 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61248.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2014 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. + +// PR61248: Transformations to recover calls made them fail typechecking in gccgo. + +package main + +func main() { + var f func(int, interface{}) + go f(0, recover()) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61253.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61253.go new file mode 100644 index 0000000000000000000000000000000000000000..696b26e64d304ca5ba212b1420230b2fd35fab08 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61253.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2014 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. + +// PR61253: gccgo incorrectly parsed the +// `RecvStmt = ExpressionList "=" RecvExpr` production. + +package main + +func main() { + c := make(chan int) + v := new(int) + b := new(bool) + select { + case (*v), (*b) = <-c: + } + +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61254.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61254.go new file mode 100644 index 0000000000000000000000000000000000000000..82e666e5c2980b5dd4d470aedc713424569eb24d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61254.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2014 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. + +// PR61254: gccgo failed to compile a slice expression with missing indices. + +package main + +func main() { + [][]int{}[:][0][0]++ +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61255.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61255.go new file mode 100644 index 0000000000000000000000000000000000000000..288fb54e517f319374046bd365a79903ab7cb78a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61255.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2014 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. + +// PR61255: gccgo failed to compile IncDec statements on variadic functions. + +package main + +func main() { + append([]byte{}, 0)[0]++ +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61258.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61258.go new file mode 100644 index 0000000000000000000000000000000000000000..e4dcb3376ab63b29358ab1ddcfc01d3d31f11101 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61258.go @@ -0,0 +1,13 @@ +// run + +// Copyright 2014 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. + +// PR61258: gccgo crashed when deleting a zero-sized key from a map. + +package main + +func main() { + delete(make(map[[0]bool]int), [0]bool{}) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61264.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61264.go new file mode 100644 index 0000000000000000000000000000000000000000..a4092f5bec31350d004553804609c72c2cef4ef1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61264.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2014 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. + +// PR61264: IncDec statements involving composite literals caused in ICE in gccgo. + +package main + +func main() { + map[int]int{}[0]++ +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61265.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61265.go new file mode 100644 index 0000000000000000000000000000000000000000..be792332f58c7799cee2635c5a8d9f5f0f51215f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61265.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2014 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. + +// PR61265: The gccgo middle-end failed to represent array composite literals +// where the elements are zero-sized values. +// This is a reduction of a program reported by GoSmith. + +package p + +var a = [1][0]int{B}[0] +var B = [0]int{} +var c = [1]struct{}{D}[0] +var D = struct{}{} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc61273.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61273.go new file mode 100644 index 0000000000000000000000000000000000000000..ed78b1ed2cd2c53858775cbc76e5109feddd8050 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc61273.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2014 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. + +// PR61273: gccgo failed to compile a SendStmt in the PostStmt of a ForClause +// that involved predefined constants. + +package main + +func main() { + c := make(chan bool, 1) + for ; false; c <- false { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc65755.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc65755.go new file mode 100644 index 0000000000000000000000000000000000000000..1e5d11605f0ec1d75659184de20134f8a05bf036 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc65755.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2015 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. + +// PR65755: Incorrect type descriptor for type defined within method. + +package main + +import "reflect" + +type S1 struct{} + +func (S1) Fix() string { + type s struct { + f int + } + return reflect.TypeOf(s{}).Field(0).Name +} + +type S2 struct{} + +func (S2) Fix() string { + type s struct { + g bool + } + return reflect.TypeOf(s{}).Field(0).Name +} + +func main() { + f1 := S1{}.Fix() + f2 := S2{}.Fix() + if f1 != "f" || f2 != "g" { + panic(f1 + f2) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc67968.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc67968.go new file mode 100644 index 0000000000000000000000000000000000000000..8db3dd8a51171a4ca5453f8edbad0b20c4441371 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc67968.go @@ -0,0 +1,14 @@ +// compiledir + +// Copyright 2015 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. + +// https://gcc.gnu.org/PR67968 + +// gccgo compiler crash building the equality and hash functions for a +// type when a return statement requires a conversion to interface +// type of a call of function defined in a different package that +// returns an unnamed type. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc78763.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc78763.go new file mode 100644 index 0000000000000000000000000000000000000000..3e3412753ecfb5f66c638e8870d541d22510be90 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc78763.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2016 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. + +// The gccgo compiler crashed while compiling this code. +// https://gcc.gnu.org/PR78763. + +package p + +import "unsafe" + +func F() int { + if unsafe.Sizeof(0) == 8 { + return 8 + } + return 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc80226.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc80226.go new file mode 100644 index 0000000000000000000000000000000000000000..530b397f0f9d1d5eeb1c4ba816f669d87f0277eb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc80226.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2017 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. + +// The gccgo compiler crashed while compiling a function that returned +// multiple zero-sized structs. +// https://gcc.gnu.org/PR80226. + +package p + +type S struct{} + +func F() (S, S) { + return S{}, S{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/gcc89321.go b/platform/dbops/binaries/go/go/test/fixedbugs/gcc89321.go new file mode 100644 index 0000000000000000000000000000000000000000..93ca6b40a512b65dbd25ee0c6cb07cb8a60697ce --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/gcc89321.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2019 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. + +// https://gcc.gnu.org/PR89321 +// gccgo compiler crash building map literals with a zero-sized value type. + +package p + +type M map[byte]struct{} + +var ( + M1 = M{1: {}, 2: {}, 3: {}} + M2 = M{1: {}, 2: {}} +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10047.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10047.go new file mode 100644 index 0000000000000000000000000000000000000000..dcbde48e8769964716274c674a39214d0975465a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10047.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2015 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. + +// Issue 10047: gccgo failed to compile a type switch where the switch variable +// and the base type of a case share the same identifier. + +package main + +func main() { + type t int + var p interface{} + switch t := p.(type) { + case t: + _ = t + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10066.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10066.go new file mode 100644 index 0000000000000000000000000000000000000000..3ea552f9feaa2c1c555a40cd25e2cc5f90f888b3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10066.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2015 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. + +// Issue 10066: constants are printed in the original form +// in export data. This is the opposite of issue 9076. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10135.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10135.go new file mode 100644 index 0000000000000000000000000000000000000000..9985e5a0ee0f87118674e169b9b1d3f13379d869 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10135.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2015 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. + +// Issue 10135: append a slice with zero-sized element used +// to always return a slice with the same data pointer as the +// old slice, even if it's nil, so this program used to panic +// with nil pointer dereference because after append, s is a +// slice with nil data pointer but non-zero len and cap. + +package main + +type empty struct{} + +func main() { + var s []empty + + s = append(s, empty{}) + + for _, v := range s { + _ = v + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10219.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10219.go new file mode 100644 index 0000000000000000000000000000000000000000..325818cff2a3bb6507d5be20f4bed585b87c3a61 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10219.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2015 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. + +// Issue 10219: failure of inlinable function that uses embedded types +// in an anonymous struct via :=. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10253.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10253.go new file mode 100644 index 0000000000000000000000000000000000000000..fafca6c733ee1e0c30d7831d076cd83d07d77244 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10253.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2015 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. + +// issue 10253: cmd/7g: bad codegen, probably regopt related + +package main + +func main() { + if !eq() { + panic("wrong value") + } +} + +var text = "abc" +var s = &str{text} + +func eq() bool { + return text[0] == s.text[0] +} + +type str struct { + text string +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10284.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10284.go new file mode 100644 index 0000000000000000000000000000000000000000..39028e756ca7867abbdf5b723ed3778e8bc9a9c4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10284.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2015 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. + +// Issue 10284: gccgo failed to allow converting a user-defined +// type whose underlying type is uintptr to unsafe.Pointer. + +package p + +import "unsafe" + +type T uintptr + +var _ unsafe.Pointer = unsafe.Pointer(T(0)) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10320.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10320.go new file mode 100644 index 0000000000000000000000000000000000000000..c7e2bab569c851c3afe189105710a36a8bdebc6a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10320.go @@ -0,0 +1,55 @@ +// run + +// Copyright 2015 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. + +// Issue 10320: 7g failed to compile a program because it attempted +// to use ZR as register. Other programs compiled but failed to +// execute correctly because they clobbered the g register. + +package main + +func main() { + var x00, x01, x02, x03, x04, x05, x06, x07, x08, x09 int + var x10, x11, x12, x13, x14, x15, x16, x17, x18, x19 int + var x20, x21, x22, x23, x24, x25, x26, x27, x28, x29 int + var x30, x31, x32 int + + _ = x00 + _ = x01 + _ = x02 + _ = x03 + _ = x04 + _ = x05 + _ = x06 + _ = x07 + _ = x08 + _ = x09 + + _ = x10 + _ = x11 + _ = x12 + _ = x13 + _ = x14 + _ = x15 + _ = x16 + _ = x17 + _ = x18 + _ = x19 + + _ = x20 + _ = x21 + _ = x22 + _ = x23 + _ = x24 + _ = x25 + _ = x26 + _ = x27 + _ = x28 + _ = x29 + + _ = x30 + _ = x31 + _ = x32 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10332.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10332.go new file mode 100644 index 0000000000000000000000000000000000000000..096b7a50554e35129701f9d07a05e8dcd326ab8c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10332.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2015 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. + +// The PkgPath of unexported fields of types defined in package main was incorrectly "" + +package main + +import ( + "fmt" + "reflect" +) + +type foo struct { + bar int +} + +func main() { + pkgpath := reflect.ValueOf(foo{}).Type().Field(0).PkgPath + if pkgpath != "main" { + fmt.Printf("BUG: incorrect PkgPath: %v", pkgpath) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10353.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10353.go new file mode 100644 index 0000000000000000000000000000000000000000..87771d400d31c82176a18717f290659b7848d5ac --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10353.go @@ -0,0 +1,49 @@ +// run + +// Copyright 2015 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. + +// issue 10253: cmd/gc: incorrect escape analysis of closures +// Partial call x.foo was not promoted to heap. + +package main + +func main() { + c := make(chan bool) + // Create a new goroutine to get a default-size stack segment. + go func() { + x := new(X) + clos(x.foo)() + c <- true + }() + <-c +} + +type X int + +func (x *X) foo() { +} + +func clos(x func()) func() { + f := func() { + print("") + x() // This statement crashed, because the partial call was allocated on the old stack. + } + // Grow stack so that partial call x becomes invalid if allocated on stack. + growstack(10000) + c := make(chan bool) + // Spoil the previous stack segment. + go func() { + c <- true + }() + <-c + return f +} + +func growstack(x int) { + if x == 0 { + return + } + growstack(x - 1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10407.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10407.go new file mode 100644 index 0000000000000000000000000000000000000000..c6461a362040a552bedb3ff119097c71fea23b02 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10407.go @@ -0,0 +1,16 @@ +// runoutput + +// Copyright 2015 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. + +// Issue 10407: gccgo failed to remove carriage returns +// from raw string literals. + +package main + +import "fmt" + +func main() { + fmt.Println("package main\nfunc main() { if `a\rb\r\nc` != \"ab\\nc\" { panic(42) }}") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10441.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10441.go new file mode 100644 index 0000000000000000000000000000000000000000..7cd26d841b66d1573e3e7b2bb097d22f80a8d0be --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10441.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2015 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 p + +func bar() { + f := func() {} + foo(&f) +} + +//go:noinline +func foo(f *func()) func() { + return *f +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10486.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10486.go new file mode 100644 index 0000000000000000000000000000000000000000..3b62cb9002fa7f87fb2f77724d9f86275fa3bc8a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10486.go @@ -0,0 +1,31 @@ +// run + +// Copyright 2015 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. + +// Issue 10486. +// Check stack walk during div by zero fault, +// especially on software divide systems. + +package main + +import "runtime" + +var A, B int + +func divZero() int { + defer func() { + if p := recover(); p != nil { + var pcs [512]uintptr + runtime.Callers(2, pcs[:]) + runtime.GC() + } + }() + return A / B +} + +func main() { + A = 1 + divZero() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10607.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10607.go new file mode 100644 index 0000000000000000000000000000000000000000..d7be61842bb7186b26c737395deee9da93d8f9df --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10607.go @@ -0,0 +1,32 @@ +// run + +//go:build linux && !ppc64 && gc && cgo + +// Copyright 2015 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. + +// Test that a -B option is passed through when using both internal +// and external linking mode. + +package main + +import ( + "fmt" + "os" + "os/exec" + "path/filepath" +) + +func main() { + test("internal") + test("external") // The 'cgo' build constraint should imply that a linker is available. +} + +func test(linkmode string) { + out, err := exec.Command("go", "run", "-ldflags", "-B=0x12345678 -linkmode="+linkmode, filepath.Join("fixedbugs", "issue10607a.go")).CombinedOutput() + if err != nil { + fmt.Printf("BUG: linkmode=%s %v\n%s\n", linkmode, err, out) + os.Exit(1) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10607a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10607a.go new file mode 100644 index 0000000000000000000000000000000000000000..51399e4ecfccab0f484a80c863f73324ee839760 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10607a.go @@ -0,0 +1,81 @@ +// skip + +// Copyright 2015 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. + +// This is built by issue10607.go with a -B option. +// Verify that we have one build-id note with the expected value. + +package main + +import ( + "bytes" + "debug/elf" + "fmt" + "os" +) + +func main() { + f, err := elf.Open("/proc/self/exe") + if err != nil { + if os.IsNotExist(err) { + return + } + fmt.Fprintln(os.Stderr, "opening /proc/self/exe:", err) + os.Exit(1) + } + + c := 0 + fail := false + for i, s := range f.Sections { + if s.Type != elf.SHT_NOTE { + continue + } + + d, err := s.Data() + if err != nil { + fmt.Fprintf(os.Stderr, "reading data of note section %d: %v\n", i, err) + continue + } + + for len(d) > 0 { + namesz := f.ByteOrder.Uint32(d) + descsz := f.ByteOrder.Uint32(d[4:]) + typ := f.ByteOrder.Uint32(d[8:]) + + an := (namesz + 3) &^ 3 + ad := (descsz + 3) &^ 3 + + if int(12+an+ad) > len(d) { + fmt.Fprintf(os.Stderr, "note section %d too short for header (%d < 12 + align(%d,4) + align(%d,4))\n", i, len(d), namesz, descsz) + break + } + + // 3 == NT_GNU_BUILD_ID + if typ == 3 && namesz == 4 && bytes.Equal(d[12:16], []byte("GNU\000")) { + id := string(d[12+an:12+an+descsz]) + if id == "\x12\x34\x56\x78" { + c++ + } else { + fmt.Fprintf(os.Stderr, "wrong build ID data: %q\n", id) + fail = true + } + } + + d = d[12+an+ad:] + } + } + + if c == 0 { + fmt.Fprintln(os.Stderr, "no build-id note") + fail = true + } else if c > 1 { + fmt.Fprintln(os.Stderr, c, "build-id notes") + fail = true + } + + if fail { + os.Exit(1) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10654.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10654.go new file mode 100644 index 0000000000000000000000000000000000000000..0600a801bb280fbd91abb975c04e5e1d3526c181 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10654.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2015 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. + +// Issue 10654: Failure to use generated temps +// for function calls etc. in boolean codegen. + +package main + +var s string + +func main() { + if (s == "this") != (s == "that") { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10700.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10700.go new file mode 100644 index 0000000000000000000000000000000000000000..25544efd9b94c6dad01909ca293964b5fe029719 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10700.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2015 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10925.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10925.go new file mode 100644 index 0000000000000000000000000000000000000000..30add82c78a9796fc4f56eb99a7c56e7feb60961 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10925.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2015 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 + +import "fmt" + +func prototype(xyz []string) {} +func main() { + var got [][]string + f := prototype + f = func(ss []string) { got = append(got, ss) } + for _, s := range []string{"one", "two", "three"} { + f([]string{s}) + } + if got[0][0] != "one" || got[1][0] != "two" || got[2][0] != "three" { + // Bug's wrong output was [[three] [three] [three]] + fmt.Println("Expected [[one] [two] [three]], got", got) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10958.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10958.go new file mode 100644 index 0000000000000000000000000000000000000000..d0b39587bb8f8f011c38bcbde5aa639773c91a19 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10958.go @@ -0,0 +1,96 @@ +// buildrun -t 10 -gcflags=-d=ssa/insert_resched_checks/on,ssa/check/on + +//go:build !nacl && !js && disabled_see_issue_18589 + +// Copyright 2016 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. + +// Test is disabled because it flakes when run in all.bash +// on some platforms, but is useful standalone to verify +// that rescheduling checks are working (and we may wish +// to investigate the flake, since it suggests that the +// loop rescheduling check may not work right on those +// platforms). + +// This checks to see that call-free infinite loops do not +// block garbage collection. IF YOU RUN IT STANDALONE without +// -gcflags=-d=ssa/insert_resched_checks/on in a not-experimental +// build, it should hang. + +package main + +import ( + "runtime" +) + +var someglobal1 int +var someglobal2 int +var someglobal3 int + +//go:noinline +func f() {} + +func standinacorner1() { + for someglobal1&1 == 0 { + someglobal1++ + someglobal1++ + } +} + +func standinacorner2(i int) { + // contains an irreducible loop containing changes to memory + if i != 0 { + goto midloop + } + +loop: + if someglobal2&1 != 0 { + goto done + } + someglobal2++ +midloop: + someglobal2++ + goto loop + +done: + return +} + +func standinacorner3() { + for someglobal3&1 == 0 { + if someglobal3&2 != 0 { + for someglobal3&3 == 2 { + someglobal3++ + someglobal3++ + someglobal3++ + someglobal3++ + } + } + someglobal3++ + someglobal3++ + someglobal3++ + someglobal3++ + } +} + +func main() { + go standinacorner1() + go standinacorner2(0) + go standinacorner3() + // println("About to stand in a corner1") + for someglobal1 == 0 { + runtime.Gosched() + } + // println("About to stand in a corner2") + for someglobal2 == 0 { + runtime.Gosched() + } + // println("About to stand in a corner3") + for someglobal3 == 0 { + runtime.Gosched() + } + // println("About to GC") + runtime.GC() + // println("Success") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10975.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10975.go new file mode 100644 index 0000000000000000000000000000000000000000..a58ccce2db16d43bfeed7540f0b4e0381fca9687 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10975.go @@ -0,0 +1,18 @@ +// errorcheck -lang=go1.17 + +// Copyright 2015 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. + +// Issue 10975: Returning an invalid interface would cause +// `internal compiler error: getinarg: not a func`. + +package main + +type I interface { + int // ERROR "interface contains embedded non-interface|embedding non-interface type" +} + +func New() I { + return struct{}{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue10977.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue10977.go new file mode 100644 index 0000000000000000000000000000000000000000..0b18c70005682b67833f86737c5b2c44d00a9d12 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue10977.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2015 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 p + +type T struct{} + +var ( + t = T{} + u = t.New() +) + +func x(T) (int, int) { return 0, 0 } + +var _, _ = x(u) + +func (T) New() T { return T{} } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11053.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11053.go new file mode 100644 index 0000000000000000000000000000000000000000..06005d3841dd1da1cc6396931073089350061ca0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11053.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2015 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. + +// Issue 11053: Compiler does not run escape analysis on an inlined +// generated method wrapper. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11053.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue11053.out new file mode 100644 index 0000000000000000000000000000000000000000..a75f73c8829459e2e7cb81279972de8bdb597c11 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11053.out @@ -0,0 +1,3 @@ +Starting +Before, *resp.V= 42 +After, *resp.V= 42 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11256.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11256.go new file mode 100644 index 0000000000000000000000000000000000000000..69fc3e8d84223f079b653fd555c4cc229ca003eb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11256.go @@ -0,0 +1,53 @@ +// run + +// Copyright 2015 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. + +// Test that stack barriers are reset when a goroutine exits without +// returning. + +package main + +import ( + "runtime" + "sync/atomic" + "time" +) + +func main() { + // Let the garbage collector run concurrently. + runtime.GOMAXPROCS(2) + + var x [100][]byte + + for i := range x { + var done int32 + + go func() { + // Use enough stack to get stack barriers, but + // not so much that we go over _FixedStack. + // There's a very narrow window here on most + // OSs, so we basically can't do anything (not + // even a time.Sleep or a channel). + var buf [1024]byte + buf[0]++ + for atomic.LoadInt32(&done) == 0 { + runtime.Gosched() + } + atomic.StoreInt32(&done, 0) + // Exit without unwinding stack barriers. + runtime.Goexit() + }() + + // Generate some garbage. + x[i] = make([]byte, 1024*1024) + + // Give GC some time to install stack barriers in the G. + time.Sleep(50 * time.Microsecond) + atomic.StoreInt32(&done, 1) + for atomic.LoadInt32(&done) == 1 { + runtime.Gosched() + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11286.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11286.go new file mode 100644 index 0000000000000000000000000000000000000000..560b7d4794251b8a2f16b1a47fd577a05769142a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11286.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2015 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. + +// Test that pointer bitmaps of types with large scalar tails are +// correctly repeated when unrolled into the heap bitmap. + +package main + +import "runtime" + +const D = 57 + +type T struct { + a [D]float64 + b map[string]int + c [D]float64 +} + +var ts []T + +func main() { + ts = make([]T, 4) + for i := range ts { + ts[i].b = make(map[string]int) + } + ts[3].b["abc"] = 42 + runtime.GC() + if ts[3].b["abc"] != 42 { + panic("bad field value") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11326.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11326.go new file mode 100644 index 0000000000000000000000000000000000000000..4ce25c5e8be00263117ff5aa2982ca58225e6013 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11326.go @@ -0,0 +1,31 @@ +// errorcheck + +// Copyright 2015 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. + +// Tests for golang.org/issue/11326. + +package main + +func main() { + // The gc compiler implementation uses the minimally required 32bit + // binary exponent, so these constants cannot be represented anymore + // internally. However, the language spec does not preclude other + // implementations from handling these. Don't check the error. + // var _ = 1e2147483647 // "constant too large" + // var _ = 1e646456993 // "constant too large" + + // Any implementation must be able to handle these constants at + // compile time (even though they cannot be assigned to a float64). + var _ = 1e646456992 // ERROR "1e\+646456992 overflows float64|floating-point constant overflow|exponent too large|overflows float64|overflows" + var _ = 1e64645699 // ERROR "1e\+64645699 overflows float64|floating-point constant overflow|exponent too large|overflows float64|overflows" + var _ = 1e6464569 // ERROR "1e\+6464569 overflows float64|floating-point constant overflow|exponent too large|overflows float64|overflows" + var _ = 1e646456 // ERROR "1e\+646456 overflows float64|floating-point constant overflow|exponent too large|overflows float64|overflows" + var _ = 1e64645 // ERROR "1e\+64645 overflows float64|floating-point constant overflow|exponent too large|overflows float64|overflows" + var _ = 1e6464 // ERROR "1e\+6464 overflows float64|floating-point constant overflow|overflows float64|overflows" + var _ = 1e646 // ERROR "1e\+646 overflows float64|floating-point constant overflow|overflows float64|overflows" + var _ = 1e309 // ERROR "1e\+309 overflows float64|floating-point constant overflow|overflows float64|overflows" + + var _ = 1e308 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11326b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11326b.go new file mode 100644 index 0000000000000000000000000000000000000000..5db083a989947bd04628f8f17d665b4f1eabe95f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11326b.go @@ -0,0 +1,48 @@ +// run + +// Does not work with gccgo, which uses a smaller (but still permitted) +// exponent size. +//go:build !gccgo + +// Copyright 2015 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 + +// Tests for golang.org/issue/11326. + +func main() { + { + const n = 1e646456992 + const d = 1e646456991 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } + { + const n = 1e64645699 + const d = 1e64645698 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } + { + const n = 1e6464569 + const d = 1e6464568 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } + { + const n = 1e646456 + const d = 1e646455 + x := n / d + if x != 10.0 { + println("incorrect value:", x) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11354.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11354.go new file mode 100644 index 0000000000000000000000000000000000000000..3980e8fcae44281206fdd9b845994643a2a5ca60 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11354.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2017 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 + +type X int + +var foo = map[int]X{} + +var bar = map[int][8]X{} + +func main() {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11359.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11359.go new file mode 100644 index 0000000000000000000000000000000000000000..6ffffede6b972d8c4f4d0965f71d9d104cd25905 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11359.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2015 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. + +// identifiers beginning with non-ASCII digits were incorrectly accepted. +// issue 11359. + +package p +var ۶ = 0 // ERROR "identifier cannot begin with digit" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11361.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11361.go new file mode 100644 index 0000000000000000000000000000000000000000..1ef8735a525a40366b4f22809a3f3fe9ac2fe895 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11361.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2016 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 a + +import "fmt" // GC_ERROR "imported and not used" + +const n = fmt // ERROR "fmt without selector|unexpected reference to package|use of package fmt not in selector" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11362.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11362.go new file mode 100644 index 0000000000000000000000000000000000000000..f4b65b0f727c705a5e6a17e5602997b2c136e417 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11362.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2015 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. + +// Issue 11362: prints empty canonical import path + +package main + +import _ "unicode//utf8" // GC_ERROR "non-canonical import path .unicode//utf8. \(should be .unicode/utf8.\)" + +func main() { +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11369.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11369.go new file mode 100644 index 0000000000000000000000000000000000000000..9df37c36499536c2d52e7eb8cd8235b687641bc2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11369.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2015 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. + +// Test that the half multiply resulting from a division +// by a constant generates correct code. + +package main + +func main() { + var _ = 7 / "0"[0] // test case from #11369 + var _ = 1 / "."[0] // test case from #11358 + var x = 0 / "0"[0] + var y = 48 / "0"[0] + var z = 5 * 48 / "0"[0] + if x != 0 { + panic("expected 0") + } + if y != 1 { + panic("expected 1") + } + if z != 5 { + panic("expected 5") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11370.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11370.go new file mode 100644 index 0000000000000000000000000000000000000000..30f2904550a26896803d6e0a9a6bb6f2b50545c9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11370.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2015 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. + +// issue 11370: cmd/compile: "0"[0] should not be a constant + +package p + +func main() { + println(-"abc"[1] >> 1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11371.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11371.go new file mode 100644 index 0000000000000000000000000000000000000000..bc10ca66273cc9f1fa82c7f053fc9d44765d8db6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11371.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 11371 (cmd/compile: meaningless error message "truncated to +// integer") + +package issue11371 + +const a int = 1.1 // ERROR "constant 1.1 truncated to integer|floating-point constant truncated to integer|truncated to int|truncated" +const b int = 1e20 // ERROR "overflows int|integer constant overflow|truncated to int|truncated" +const c int = 1 + 1e-70 // ERROR "constant truncated to integer|truncated to int|truncated" +const d int = 1 - 1e-70 // ERROR "constant truncated to integer|truncated to int|truncated" +const e int = 1.00000001 // ERROR "constant truncated to integer|truncated to int|truncated" +const f int = 0.00000001 // ERROR "constant 1e-08 truncated to integer|floating-point constant truncated to integer|truncated to int|truncated" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11590.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11590.go new file mode 100644 index 0000000000000000000000000000000000000000..9f8978334314c28afbcdd263521d22421926d8d1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11590.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2015 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 p + +var _ = int8(4) * 300 // ERROR "overflows int8" +var _ = complex64(1) * 1e200 // ERROR "complex real part overflow|overflows complex64" +var _ = complex128(1) * 1e500 // ERROR "complex real part overflow|overflows complex128" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11610.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11610.go new file mode 100644 index 0000000000000000000000000000000000000000..8d68c98f2d437d543d2294baf34edcf361459455 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11610.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2015 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. + +// Test an internal compiler error on ? symbol in declaration +// following an empty import. + +package a +var? // ERROR "invalid character U\+003F '\?'|invalid character 0x3f in input file" + +var x int // ERROR "unexpected var|expected identifier|expected type" + +func main() { +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11610a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11610a.go new file mode 100644 index 0000000000000000000000000000000000000000..bbf60b6b049df693a08dbeceee7e40af8aae35c2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11610a.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2015 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. + +// Test an internal compiler error on ? symbol in declaration +// following an empty import. + +package a +import"" // ERROR "import path is empty|invalid import path \(empty string\)" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11614.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11614.go new file mode 100644 index 0000000000000000000000000000000000000000..e8d6badfb90fc268ab7c34c38bc25ce66eec2320 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11614.go @@ -0,0 +1,26 @@ +// errorcheck -lang=go1.17 + +// Copyright 2015 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. + +// Test that incorrect expressions involving wrong anonymous interface +// do not generate panics in Type Stringer. +// Does not compile. + +package main + +type I interface { + int // ERROR "interface contains embedded non-interface|embedding non-interface type int requires" +} + +func n() { + (I) // GC_ERROR "is not an expression" +} + +func m() { + (interface{int}) // ERROR "interface contains embedded non-interface|embedding non-interface type int requires" "type interface { int } is not an expression|\(interface{int}\) \(type\) is not an expression" +} + +func main() { +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11656.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11656.go new file mode 100644 index 0000000000000000000000000000000000000000..2d746891d62a6319a4df95472ff5b9ddce20e0c2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11656.go @@ -0,0 +1,21 @@ +// runindir + +// Copyright 2022 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. + +// Issue 11656: runtime: jump to bad PC missing good traceback + +// windows doesn't work, because Windows exception handling +// delivers signals based on the current PC, and that current PC +// doesn't go into the Go runtime. + +// wasm does not work, because the linear memory is not executable. + +// This test doesn't work on gccgo/GoLLVM, because they will not find +// any unwind information for the artificial function, and will not be +// able to unwind past that point. + +//go:build !windows && !wasm && !gccgo + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11674.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11674.go new file mode 100644 index 0000000000000000000000000000000000000000..183ed133de7767da2c34603e9103925e85d0fa55 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11674.go @@ -0,0 +1,40 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 11674: cmd/compile: does not diagnose constant division by +// zero + +package p + +const x complex64 = 0 +const y complex128 = 0 + +var _ = x / 1e-20 +var _ = x / 1e-50 // GC_ERROR "division by zero" +var _ = x / 1e-1000 // GC_ERROR "division by zero" +var _ = x / 1e-20i +var _ = x / 1e-50i // GC_ERROR "division by zero" +var _ = x / 1e-1000i // GC_ERROR "division by zero" + +var _ = x / 1e-45 // smallest positive float32 + +var _ = x / (1e-20 + 1e-20i) +var _ = x / (1e-50 + 1e-20i) +var _ = x / (1e-20 + 1e-50i) +var _ = x / (1e-50 + 1e-50i) // GC_ERROR "division by zero" +var _ = x / (1e-1000 + 1e-1000i) // GC_ERROR "division by zero" + +var _ = y / 1e-50 +var _ = y / 1e-1000 // GC_ERROR "division by zero" +var _ = y / 1e-50i +var _ = y / 1e-1000i // GC_ERROR "division by zero" + +var _ = y / 5e-324 // smallest positive float64 + +var _ = y / (1e-50 + 1e-50) +var _ = y / (1e-1000 + 1e-50i) +var _ = y / (1e-50 + 1e-1000i) +var _ = y / (1e-1000 + 1e-1000i) // GC_ERROR "division by zero" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11699.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11699.go new file mode 100644 index 0000000000000000000000000000000000000000..755e9a1fde62391c8a4c5468fd7c648418b27f84 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11699.go @@ -0,0 +1,12 @@ +// compile + +// Copyright 2015 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. + +// issue 11699; used to fail with duplicate _.args_stackmap symbols. + +package p + +func _() +func _() diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11737.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11737.go new file mode 100644 index 0000000000000000000000000000000000000000..aa4abbc327407ae7770966d3fc93c0c186be727b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11737.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2015 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. + +// Issue 11737 - invalid == not being caught until generated switch code was compiled + +package p + +func f() + +func s(x interface{}) { + switch x { + case f: // ERROR "invalid case f \(type func\(\)\) in switch \(incomparable type\)|can only be compared to nil" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11750.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11750.go new file mode 100644 index 0000000000000000000000000000000000000000..d5a2b22dda0f0be3ee1b523877978b601fd20ea1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11750.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2015 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. + +// Issue 11750: mkdotargslice: typecheck failed + +package main + +func main() { + fn := func(names string) { + + } + func(names ...string) { + for _, name := range names { + fn(name) + } + }("one", "two") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11771.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11771.go new file mode 100644 index 0000000000000000000000000000000000000000..0c6b769d720800160fecd7d91f3198604f0d7444 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11771.go @@ -0,0 +1,65 @@ +// run + +//go:build !nacl && !js && !wasip1 && gc + +// Copyright 2015 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. + +// Issue 11771: Magic comments should ignore carriage returns. + +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "runtime" +) + +func main() { + if runtime.Compiler != "gc" { + return + } + + dir, err := ioutil.TempDir("", "go-issue11771") + if err != nil { + log.Fatalf("creating temp dir: %v\n", err) + } + defer os.RemoveAll(dir) + + // The go:nowritebarrier magic comment is only permitted in + // the runtime package. So we confirm that the compilation + // fails. + + var buf bytes.Buffer + fmt.Fprintln(&buf, ` +package main + +func main() { +} +`) + fmt.Fprintln(&buf, "//go:nowritebarrier\r") + fmt.Fprintln(&buf, ` +func x() { +} +`) + + if err := ioutil.WriteFile(filepath.Join(dir, "x.go"), buf.Bytes(), 0666); err != nil { + log.Fatal(err) + } + + cmd := exec.Command("go", "tool", "compile", "-p=p", "x.go") + cmd.Dir = dir + output, err := cmd.CombinedOutput() + if err == nil { + log.Fatal("compile succeeded unexpectedly") + } + if !bytes.Contains(output, []byte("only allowed in runtime")) { + log.Fatalf("wrong error message from compiler; got:\n%s\n", output) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11790.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11790.go new file mode 100644 index 0000000000000000000000000000000000000000..096b297f990d02a08997b180fa5fafe15860b6ad --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11790.go @@ -0,0 +1,36 @@ +// compile + +// Copyright 2015 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. + +// Issue 11790: Incorrect error following named pointer dereference on field + +package main + +import "fmt" + +type T0 struct { + x int +} + +func (*T0) M0() { + fmt.Println("M0") +} + +type T2 struct { + *T0 +} + +type Q *T2 + +func main() { + // If run, expected output is + // 42 + // M0 + t0 := T0{42} + t2 := T2{&t0} + var q Q = &t2 + fmt.Println(q.x) // Comment out either this line or the next line and the program works + (*q).T0.M0() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11945.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11945.go new file mode 100644 index 0000000000000000000000000000000000000000..218d07a6939db25867d738c1b7ac5d0c82e9a94f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11945.go @@ -0,0 +1,75 @@ +// run + +// Copyright 2017 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 + +import "fmt" + +// issue 17446 +const ( + _ = real(0) // from bug report + _ = imag(0) // from bug report + + // same as above, but exported for #43891 + Real0 = real(0) + Imag0 = imag(0) + + // if the arguments are untyped, the results must be untyped + // (and compatible with types that can represent the values) + _ int = real(1) + _ int = real('a') + _ int = real(2.0) + _ int = real(3i) + + _ float32 = real(1) + _ float32 = real('a') + _ float32 = real(2.1) + _ float32 = real(3.2i) + + _ float64 = real(1) + _ float64 = real('a') + _ float64 = real(2.1) + _ float64 = real(3.2i) + + _ int = imag(1) + _ int = imag('a') + _ int = imag(2.1 + 3i) + _ int = imag(3i) + + _ float32 = imag(1) + _ float32 = imag('a') + _ float32 = imag(2.1 + 3.1i) + _ float32 = imag(3i) + + _ float64 = imag(1) + _ float64 = imag('a') + _ float64 = imag(2.1 + 3.1i) + _ float64 = imag(3i) +) + +var tests = []struct { + code string + got, want interface{} +}{ + {"real(1)", real(1), 1.0}, + {"real('a')", real('a'), float64('a')}, + {"real(2.0)", real(2.0), 2.0}, + {"real(3.2i)", real(3.2i), 0.0}, + + {"imag(1)", imag(1), 0.0}, + {"imag('a')", imag('a'), 0.0}, + {"imag(2.1 + 3.1i)", imag(2.1 + 3.1i), 3.1}, + {"imag(3i)", imag(3i), 3.0}, +} + +func main() { + // verify compile-time evaluated constant expressions + for _, test := range tests { + if test.got != test.want { + panic(fmt.Sprintf("%s: %v (%T) != %v (%T)", test.code, test.got, test.got, test.want, test.want)) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue11987.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue11987.go new file mode 100644 index 0000000000000000000000000000000000000000..9b665dc635e89055b53b95c12b1dfd0d02a5a564 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue11987.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2015 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. + +// Issue 11987. The ppc64 SRADCC instruction was misassembled in a way +// lost bit 5 of the immediate so v>>32 was assembled as v>>0. SRADCC +// is only ever inserted by peep so it's hard to be sure when it will +// be used. This formulation worked when the bug was fixed. + +package main + +import "fmt" + +var v int64 = 0x80000000 + +func main() { + s := fmt.Sprintf("%v", v>>32 == 0) + if s != "true" { + fmt.Printf("BUG: v>>32 == 0 evaluated as %q\n", s) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12006.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12006.go new file mode 100644 index 0000000000000000000000000000000000000000..e878bc48e241e11befd77c30a2790c07a9d2058a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12006.go @@ -0,0 +1,174 @@ +// errorcheck -0 -m -l + +// Copyright 2015 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. + +// Test escape analysis through ... parameters. + +package foo + +func FooN(vals ...*int) (s int) { // ERROR "vals does not escape" + for _, v := range vals { + s += *v + } + return s +} + +// Append forces heap allocation and copies entries in vals to heap, therefore they escape to heap. +func FooNx(x *int, vals ...*int) (s int) { // ERROR "leaking param: x" "leaking param content: vals" + vals = append(vals, x) + return FooN(vals...) +} + +var sink []*int + +func FooNy(x *int, vals ...*int) (s int) { // ERROR "leaking param: x" "leaking param: vals" + vals = append(vals, x) + sink = vals + return FooN(vals...) +} + +func FooNz(vals ...*int) (s int) { // ERROR "leaking param: vals" + sink = vals + return FooN(vals...) +} + +func TFooN() { + for i := 0; i < 1000; i++ { + var i, j int + FooN(&i, &j) // ERROR "... argument does not escape" + } +} + +func TFooNx() { + for i := 0; i < 1000; i++ { + var i, j, k int // ERROR "moved to heap: i" "moved to heap: j" "moved to heap: k" + FooNx(&k, &i, &j) // ERROR "... argument does not escape" + } +} + +func TFooNy() { + for i := 0; i < 1000; i++ { + var i, j, k int // ERROR "moved to heap: i" "moved to heap: j" "moved to heap: k" + FooNy(&k, &i, &j) // ERROR "... argument escapes to heap" + } +} + +func TFooNz() { + for i := 0; i < 1000; i++ { + var i, j int // ERROR "moved to heap: i" "moved to heap: j" + FooNz(&i, &j) // ERROR "... argument escapes to heap" + } +} + +var isink *int32 + +func FooI(args ...interface{}) { // ERROR "leaking param content: args" + for i := 0; i < len(args); i++ { + switch x := args[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + isink = x + case string: + println("is string") + } + } +} + +func TFooI() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + FooI(a, b, c) // ERROR "a escapes to heap" "b escapes to heap" "... argument does not escape" +} + +func FooJ(args ...interface{}) *int32 { // ERROR "leaking param: args to result ~r0 level=1" + for i := 0; i < len(args); i++ { + switch x := args[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + return x + case string: + println("is string") + } + } + return nil +} + +func TFooJ1() { + a := int32(1) + b := "cat" + c := &a + FooJ(a, b, c) // ERROR "a does not escape" "b does not escape" "... argument does not escape" +} + +func TFooJ2() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + isink = FooJ(a, b, c) // ERROR "a escapes to heap" "b escapes to heap" "... argument does not escape" +} + +type fakeSlice struct { + l int + a *[4]interface{} +} + +func FooK(args fakeSlice) *int32 { // ERROR "leaking param: args to result ~r0 level=1" + for i := 0; i < args.l; i++ { + switch x := (*args.a)[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + return x + case string: + println("is string") + } + } + return nil +} + +func TFooK2() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + fs := fakeSlice{3, &[4]interface{}{a, b, c, nil}} // ERROR "a escapes to heap" "b escapes to heap" "&\[4\]interface {}{...} does not escape" + isink = FooK(fs) +} + +func FooL(args []interface{}) *int32 { // ERROR "leaking param: args to result ~r0 level=1" + for i := 0; i < len(args); i++ { + switch x := args[i].(type) { + case nil: + println("is nil") + case int32: + println("is int32") + case *int32: + println("is *int32") + return x + case string: + println("is string") + } + } + return nil +} + +func TFooL2() { + a := int32(1) // ERROR "moved to heap: a" + b := "cat" + c := &a + s := []interface{}{a, b, c} // ERROR "a escapes to heap" "b escapes to heap" "\[\]interface {}{...} does not escape" + isink = FooL(s) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12108.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12108.go new file mode 100644 index 0000000000000000000000000000000000000000..c7a742513af0986ed661d25b62521a894db2f317 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12108.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2015 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. + +// A generated method with a return value large enough to be +// initialized by duffzero is not a leaf method, which violated +// assumptions made by cmd/internal/obj/ppc64. + +package main + +const N = 9 // values > 8 cause (Super).Method to use duffzero + +type Base struct { +} + +func (b *Base) Method() (x [N]uintptr) { + return +} + +type Super struct { + Base +} + +type T interface { + Method() [N]uintptr +} + +func f(q T) { + q.Method() +} + +func main() { + var s Super + f(&s) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12133.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12133.go new file mode 100644 index 0000000000000000000000000000000000000000..bbf9fb0063f1a645777709928d373bb55b008f41 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12133.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2015 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. + +// Issue 12133. The CX register was getting clobbered +// because we did not keep track of its allocation correctly. + +package main + +import "fmt" + +func main() { + want := uint(48) + got := f1(48) + if got != want { + fmt.Println("got", got, ", wanted", want) + panic("bad") + } +} + +//go:noinline +func f1(v1 uint) uint { + return v1 >> ((1 >> v1) + (1 >> v1)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12226.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12226.go new file mode 100644 index 0000000000000000000000000000000000000000..22467116c19b83134e2ece328757353c5d5fa3af --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12226.go @@ -0,0 +1,15 @@ +// run + +// Copyright 2015 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 + +import "fmt" + +func main() { + if []byte("foo")[0] == []byte("b")[0] { + fmt.Println("BUG: \"foo\" and \"b\" appear to have the same first byte") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12347.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12347.go new file mode 100644 index 0000000000000000000000000000000000000000..fc5678e3ed7d6ff60fdb11dc44ca621585c5e6fd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12347.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2015 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 p + +func f_ssa(x int, p *int) { + if false { + y := x + 5 + for { + *p = y + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12411.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12411.go new file mode 100644 index 0000000000000000000000000000000000000000..19275d94a2a2c7ff0b1fb048ea42a65589f3bbd1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12411.go @@ -0,0 +1,25 @@ +// run + +//go:build !386 + +// Copyright 2015 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. + +// Issue 12411. Loss of AX during %. + +package main + +func main() { + x := f(4) + if x != 0 { + println("BUG: x=", x) + } +} + +//go:noinline +func f(x int) int { + // AX was live on entry to one of the % code generations, + // and the % code generation smashed it. + return ((2 * x) % 3) % (2 % ((x << 2) ^ (x % 3))) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12413.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12413.go new file mode 100644 index 0000000000000000000000000000000000000000..a054765118bde218d695c0300438dadce0d0a467 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12413.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2015 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. + +// issue 12413: invalid variable name x in type switch: code would fail +// to compile if the variable used in the short variable declaration was +// previously declared as a constant. + +package main + +func main() { + const x = 42 + switch x := interface{}(nil).(type) { + default: + _ = x + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12525.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12525.go new file mode 100644 index 0000000000000000000000000000000000000000..4a54eabad52dbde3599da27b2fd7c11416f112f2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12525.go @@ -0,0 +1,26 @@ +// errorcheck + +// Copyright 2016 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. + +// Issue 12525: confusing error trying to increment boolean value + +package main + +func main() { + var i int + i++ + + var f float64 + f++ + + var c complex128 + c++ + + var b bool + b++ // ERROR "invalid operation: b\+\+ \(non-numeric type bool\)" + + var s string + s-- // ERROR "invalid operation: s-- \(non-numeric type string\)" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12536.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12536.go new file mode 100644 index 0000000000000000000000000000000000000000..ceeaec4360ea09e05fa90831dd88069de415b2e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12536.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2017 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. + +// Issue 12536: compiler crashes while checking keys in a map literal for equality + +package p + +func main() { + m1 := map[interface{}]interface{}{ + nil: 0, + true: 1, + } + m2 := map[interface{}]interface{}{ + true: 1, + nil: 0, + } + println(len(m1)) + println(len(m2)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12577.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12577.go new file mode 100644 index 0000000000000000000000000000000000000000..249b4f24325cd4c5d7ec79961ae4a518d22f7718 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12577.go @@ -0,0 +1,66 @@ +// run + +// Copyright 2015 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. + +// Issue 12577: Test that there are no -0 floating-point constants. + +package main + +import "math" + +const ( + z0 = 0.0 + z1 = -0.0 + z2 = -z0 + z3 = -z2 +) + +var ( + x0 float32 = z0 + x1 float32 = z1 + x2 float32 = z2 + x3 float32 = z3 + + y0 float64 = z0 + y1 float64 = z1 + y2 float64 = z2 + y3 float64 = z3 +) + +func test32(f float32) { + if f != 0 || math.Signbit(float64(f)) { + println("BUG: got", f, "want 0.0") + return + } +} + +func test64(f float64) { + if f != 0 || math.Signbit(f) { + println("BUG: got", f, "want 0.0") + return + } +} + +func main() { + if f := -x0; f != 0 || !math.Signbit(float64(f)) { + println("BUG: got", f, "want -0.0") + } + + test32(-0.0) + test32(x0) + test32(x1) + test32(x2) + test32(x3) + + if f := -y0; f != 0 || !math.Signbit(f) { + println("BUG: got", f, "want -0.0") + } + + test64(-0.0) + test64(y0) + test64(y1) + test64(y2) + test64(y3) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12588.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12588.go new file mode 100644 index 0000000000000000000000000000000000000000..dc8111198c49d24e87ebe8b1bcd8e473bcea3b3a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12588.go @@ -0,0 +1,88 @@ +// errorcheck -0 -m -l + +// Copyright 2015 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. + +// Tests escape analysis for range of arrays. +// Compiles but need not run. Inlining is disabled. + +package main + +type A struct { + b [3]uint64 +} + +type B struct { + b [3]*uint64 +} + +func f(a A) int { + for i, x := range &a.b { + if x != 0 { + return 64*i + int(x) + } + } + return 0 +} + +func g(a *A) int { // ERROR "a does not escape" + for i, x := range &a.b { + if x != 0 { + return 64*i + int(x) + } + } + return 0 +} + +func h(a *B) *uint64 { // ERROR "leaking param: a to result ~r0 level=1" + for i, x := range &a.b { + if i == 0 { + return x + } + } + return nil +} + +func h2(a *B) *uint64 { // ERROR "leaking param: a to result ~r0 level=1" + p := &a.b + for i, x := range p { + if i == 0 { + return x + } + } + return nil +} + +// Seems like below should be level=1, not 0. +func k(a B) *uint64 { // ERROR "leaking param: a to result ~r0 level=0" + for i, x := range &a.b { + if i == 0 { + return x + } + } + return nil +} + +var sink *uint64 + +func main() { + var a1, a2 A + var b1, b2, b3, b4 B + var x1, x2, x3, x4 uint64 // ERROR "moved to heap: x1" "moved to heap: x3" + b1.b[0] = &x1 + b2.b[0] = &x2 + b3.b[0] = &x3 + b4.b[0] = &x4 + f(a1) + g(&a2) + sink = h(&b1) + h(&b2) + sink = h2(&b1) + h2(&b4) + x1 = 17 + println("*sink=", *sink) // Verify that sink addresses x1 + x3 = 42 + sink = k(b3) + println("*sink=", *sink) // Verify that sink addresses x3 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12621.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12621.go new file mode 100644 index 0000000000000000000000000000000000000000..379a362d73b2d8c6f5c71a52df777f8ec9109951 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12621.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2018 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. + +// Issues 12576 and 12621: Negative untyped floating point constants +// with small magnitude round to 0, not negative zero. + +package main + +import "math" + +var m = -1e-10000 + +func main() { + if math.Signbit(m) { + panic(m) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12677.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12677.go new file mode 100644 index 0000000000000000000000000000000000000000..6ad7161b2a57436262b50d6914c4b2885abf8835 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12677.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2015 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. + +// Issue 12677: Type loss during export/import of inlined function body. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12686.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12686.go new file mode 100644 index 0000000000000000000000000000000000000000..bde425501483df3c7177acf01948555707a12fe1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12686.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2015 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. + +// golang.org/issue/12686. +// interesting because it's a non-constant but ideal value +// and we used to incorrectly attach a constant Val to the Node. + +package p + +func f(i uint) uint { + x := []uint{1 << i} + return x[0] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue12944.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue12944.go new file mode 100644 index 0000000000000000000000000000000000000000..59379f1aa6c011f3bff52c62cc7ead4f6424990d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue12944.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2015 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 + +import "unsafe" + +const ( + _ = unsafe.Sizeof([0]byte{}[0]) // ERROR "out of bounds" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue1304.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue1304.go new file mode 100644 index 0000000000000000000000000000000000000000..9e0ca5ae3f6af2c6fc43e639c9123a25167d9c5e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue1304.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2014 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 + +var a = 1 + +func main() { + defer func() { + recover() + if a != 2 { + println("BUG a =", a) + } + }() + a = 2 + b := a - a + c := 4 + a = c / b + a = 3 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13160.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13160.go new file mode 100644 index 0000000000000000000000000000000000000000..c21ecf671a25376997ac5c1861c29c04184b5118 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13160.go @@ -0,0 +1,70 @@ +// run + +// Copyright 2015 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 + +import ( + "fmt" + "runtime" +) + +const N = 100000 + +func main() { + // Allocate more Ps than processors. This raises + // the chance that we get interrupted by the OS + // in exactly the right (wrong!) place. + p := runtime.NumCPU() + runtime.GOMAXPROCS(2 * p) + + // Allocate some pointers. + ptrs := make([]*int, p) + for i := 0; i < p; i++ { + ptrs[i] = new(int) + } + + // Arena where we read and write pointers like crazy. + collider := make([]*int, p) + + done := make(chan struct{}, 2*p) + + // Start writers. They alternately write a pointer + // and nil to a slot in the collider. + for i := 0; i < p; i++ { + i := i + go func() { + for j := 0; j < N; j++ { + // Write a pointer using memmove. + copy(collider[i:i+1], ptrs[i:i+1]) + // Write nil using memclr. + // (This is a magic loop that gets lowered to memclr.) + r := collider[i : i+1] + for k := range r { + r[k] = nil + } + } + done <- struct{}{} + }() + } + // Start readers. They read pointers from slots + // and make sure they are valid. + for i := 0; i < p; i++ { + i := i + go func() { + for j := 0; j < N; j++ { + var ptr [1]*int + copy(ptr[:], collider[i:i+1]) + if ptr[0] != nil && ptr[0] != ptrs[i] { + panic(fmt.Sprintf("bad pointer read %p!", ptr[0])) + } + } + done <- struct{}{} + }() + } + for i := 0; i < 2*p; i++ { + <-done + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13162.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13162.go new file mode 100644 index 0000000000000000000000000000000000000000..f8b3150c3eafa119e65c2c518f68333c109b1048 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13162.go @@ -0,0 +1,82 @@ +// run + +// Copyright 2016 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. + +// Ensure that range loops over a string have the requisite side-effects. + +package main + +import ( + "fmt" + "os" +) + +func check(n int) { + var i int + var r rune + + b := make([]byte, n) + for i = range b { + b[i] = byte(i + 1) + } + s := string(b) + + // When n == 0, i is untouched by the range loop. + // Picking an initial value of -1 for i makes the + // "want" calculation below correct in all cases. + i = -1 + for i = range s { + b[i] = s[i] + } + if want := n - 1; i != want { + fmt.Printf("index after range with side-effect = %d want %d\n", i, want) + os.Exit(1) + } + + i = -1 + r = '\x00' + for i, r = range s { + b[i] = byte(r) + } + if want := n - 1; i != want { + fmt.Printf("index after range with side-effect = %d want %d\n", i, want) + os.Exit(1) + } + if want := rune(n); r != want { + fmt.Printf("rune after range with side-effect = %q want %q\n", r, want) + os.Exit(1) + } + + i = -1 + // i is shadowed here, so its value should be unchanged. + for i := range s { + b[i] = s[i] + } + if want := -1; i != want { + fmt.Printf("index after range without side-effect = %d want %d\n", i, want) + os.Exit(1) + } + + i = -1 + r = -1 + // i and r are shadowed here, so their values should be unchanged. + for i, r := range s { + b[i] = byte(r) + } + if want := -1; i != want { + fmt.Printf("index after range without side-effect = %d want %d\n", i, want) + os.Exit(1) + } + if want := rune(-1); r != want { + fmt.Printf("rune after range without side-effect = %q want %q\n", r, want) + os.Exit(1) + } +} + +func main() { + check(0) + check(1) + check(15) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13169.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13169.go new file mode 100644 index 0000000000000000000000000000000000000000..03c52e2951d7c132462841d3fbe104f506aeec69 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13169.go @@ -0,0 +1,49 @@ +// run + +// Copyright 2015 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 + +type T struct { + a, b, c int +} + +func usestack() { + usestack1(32) +} +func usestack1(d int) byte { + if d == 0 { + return 0 + } + var b [1024]byte + usestack1(d - 1) + return b[3] +} + +const n = 100000 + +func main() { + c := make(chan interface{}) + done := make(chan bool) + + for i := 0; i < 10; i++ { + go func() { + for j := 0; j < n; j++ { + c <- new(T) + } + done <- true + }() + go func() { + for j := 0; j < n; j++ { + _ = (<-c).(*T) + usestack() + } + done <- true + }() + } + for i := 0; i < 20; i++ { + <-done + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13171.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13171.go new file mode 100644 index 0000000000000000000000000000000000000000..addb872781aa472714ab1fd0e20e5010f2b1e1dc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13171.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2015 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 + +// Make sure the compiler knows that DUFFCOPY clobbers X0 + +import "fmt" + +//go:noinline +func f(x float64) float64 { + // y is allocated to X0 + y := x + 5 + // marshals z before y. Marshaling z + // calls DUFFCOPY. + return g(z, y) +} + +//go:noinline +func g(b [64]byte, y float64) float64 { + return y +} + +var z [64]byte + +func main() { + got := f(5) + if got != 10 { + panic(fmt.Sprintf("want 10, got %f", got)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13248.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13248.go new file mode 100644 index 0000000000000000000000000000000000000000..e23ba47b5867a1ec11f79702a0970741d9c8ac47 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13248.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2015 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. + +// This program caused an infinite loop with the recursive-descent parser. + +package main + +func main() { + foo( // GCCGO_ERROR "undefined name" +} // ERROR "unexpected }|expected operand|missing" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13261.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13261.go new file mode 100644 index 0000000000000000000000000000000000000000..a944f3a9b57240cec7740f237e747ac9a2db8357 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13261.go @@ -0,0 +1,29 @@ +// compile + +// Copyright 2015 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. + +// Taking the address of a parenthesized composite literal is permitted. + +package main + +type T struct{} + +func main() { + _ = &T{} + _ = &(T{}) + _ = &((T{})) + + _ = &struct{}{} + _ = &(struct{}{}) + _ = &((struct{}{})) + + switch (&T{}) {} + switch &(T{}) {} + switch &((T{})) {} + + switch &struct{}{} {} + switch &(struct{}{}) {} + switch &((struct{}{})) {} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13262.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13262.go new file mode 100644 index 0000000000000000000000000000000000000000..8837c007989d9b743a37c6f89f5abb2810af0ca8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13262.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2016 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. + +// Issue 13262: cmd/compile: bogus "fallthrough +// statement out of place" error + +package p + +func f() int { + var a int + switch a { + case 0: + return func() int { return 1 }() + fallthrough + default: + } + return 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13263.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13263.go new file mode 100644 index 0000000000000000000000000000000000000000..1933f2b5c5ccd7720ce2f880f15c95cfb80aa207 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13263.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2016 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 b + +var ( + x uint + y = x + z = uintptr(y) + a = uint32(y) + b = uint64(y) +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13265.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13265.go new file mode 100644 index 0000000000000000000000000000000000000000..0a393a3614373f799c69731eecd894a0d8ad2999 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13265.go @@ -0,0 +1,17 @@ +// errorcheck -0 -race + +//go:build (linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64) + +// Copyright 2017 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. + +// Issue 13265: nil pointer deref. + +package p + +func f() { + var c chan chan chan int + for ; ; <-<-<-c { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13266.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13266.go new file mode 100644 index 0000000000000000000000000000000000000000..73c9e16bcc247f4b2f077d22ba828bd813e3b198 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13266.go @@ -0,0 +1,10 @@ +// errorcheck + +// Copyright 2015 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. + +// Offending character % must not be interpreted as +// start of format verb when emitting error message. + +package% // ERROR "unexpected %|package name must be an identifier|after package clause|expected declaration" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13268.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13268.go new file mode 100644 index 0000000000000000000000000000000000000000..da54b708a08224e714552395f296e2a6c8c1a43f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13268.go @@ -0,0 +1,44 @@ +// run + +//go:build gc + +// Copyright 2015 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. + +// Test error message when EOF is encountered in the +// middle of a BOM. +// +// Since the error requires an EOF, we cannot use the +// errorcheckoutput mechanism. + +package main + +import ( + "io/ioutil" + "log" + "os" + "os/exec" + "strings" +) + +func main() { + // create source + f, err := ioutil.TempFile("", "issue13268-") + if err != nil { + log.Fatalf("could not create source file: %v", err) + } + f.Write([]byte("package p\n\nfunc \xef\xef")) // if this fails, we will die later + f.Close() + defer os.Remove(f.Name()) + + // compile and test output + cmd := exec.Command("go", "tool", "compile", f.Name()) + out, err := cmd.CombinedOutput() + if err == nil { + log.Fatalf("expected cmd/compile to fail") + } + if strings.HasPrefix(string(out), "illegal UTF-8 sequence") { + log.Fatalf("error %q not found", out) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13273.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13273.go new file mode 100644 index 0000000000000000000000000000000000000000..ea729d6080324514983f6927112dee253681b3c0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13273.go @@ -0,0 +1,55 @@ +// errorcheck + +// Copyright 2015 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. + +// Check that we correctly construct (and report errors) +// for unary expressions of the form <-x where we only +// know after parsing x whether <-x is a receive operation +// or a channel type. + +package n + +func f() { + // test case from issue 13273 + <-chan int((chan int)(nil)) + + <-chan int(nil) + <-chan chan int(nil) + <-chan chan chan int(nil) + <-chan chan chan chan int(nil) + <-chan chan chan chan chan int(nil) + + <-chan<-chan int(nil) + <-chan<-chan<-chan int(nil) + <-chan<-chan<-chan<-chan int(nil) + <-chan<-chan<-chan<-chan<-chan int(nil) + + <-chan (<-chan int)(nil) + <-chan (<-chan (<-chan int))(nil) + <-chan (<-chan (<-chan (<-chan int)))(nil) + <-chan (<-chan (<-chan (<-chan (<-chan int))))(nil) + + <-(<-chan int)(nil) + <-(<-chan chan int)(nil) + <-(<-chan chan chan int)(nil) + <-(<-chan chan chan chan int)(nil) + <-(<-chan chan chan chan chan int)(nil) + + <-(<-chan<-chan int)(nil) + <-(<-chan<-chan<-chan int)(nil) + <-(<-chan<-chan<-chan<-chan int)(nil) + <-(<-chan<-chan<-chan<-chan<-chan int)(nil) + + <-(<-chan (<-chan int))(nil) + <-(<-chan (<-chan (<-chan int)))(nil) + <-(<-chan (<-chan (<-chan (<-chan int))))(nil) + <-(<-chan (<-chan (<-chan (<-chan (<-chan int)))))(nil) + + type _ <-<-chan int // ERROR "unexpected <-, expected chan|expected .*chan.*" + <-<-chan int // ERROR "unexpected <-, expected chan|expecting {" (new parser: same error as for type decl) + + type _ <-chan<-int // ERROR "unexpected int, expected chan|expected .*chan.*|expected chan|expected .*;.* or .*}.* or newline" + <-chan<-int // ERROR "unexpected int, expected chan|expecting {" (new parser: same error as for type decl) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13274.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13274.go new file mode 100644 index 0000000000000000000000000000000000000000..816bd9b8f27320d459278892d2c274b765dd1879 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13274.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2015 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. + +// Check that we don't ignore EOF. + +package p + +var f = func() { // ERROR "unexpected EOF|expected .*}.*" \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13319.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13319.go new file mode 100644 index 0000000000000000000000000000000000000000..7e1df3e45ee8a514c8bc384552be56e5887e9963 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13319.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2015 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(int, int) { + switch x { + case 1: + f(1, g() // ERROR "expecting \)|possibly missing comma or \)" + case 2: + f() + case 3: + f(1, g() // ERROR "expecting \)|possibly missing comma or \)" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13337.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13337.go new file mode 100644 index 0000000000000000000000000000000000000000..81f984b7322b1e9600c49695edde970ab74aab56 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13337.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2016 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. + +// Issue 13337: The Go compiler limited how deeply embedded types +// were searched for promoted fields and methods. + +package s + +type S0 struct{ f int } +func (S0) m() {} + +type S1 struct{ S0 } +type S2 struct{ S1 } +type S3 struct{ S2 } +type S4 struct{ S3 } +type S5 struct{ S4 } +type S6 struct{ S5 } +type S7 struct{ S6 } +type S8 struct{ S7 } +type S9 struct{ S8 } +type S10 struct{ S9 } +type S11 struct{ S10 } +type S12 struct{ S11 } +type S13 struct{ S12 } + +var _ = S13{}.f +var _ = S13.m diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13365.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13365.go new file mode 100644 index 0000000000000000000000000000000000000000..02c6e0369844e0d63c92f65e350ad3f99cc9d530 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13365.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2015 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. + +// issue 13365: confusing error message (array vs slice) + +package main + +var t struct{} + +func main() { + _ = []int{-1: 0} // ERROR "index must be non\-negative integer constant|index expression is negative|must not be negative" + _ = [10]int{-1: 0} // ERROR "index must be non\-negative integer constant|index expression is negative|must not be negative" + _ = [...]int{-1: 0} // ERROR "index must be non\-negative integer constant|index expression is negative|must not be negative" + + _ = []int{100: 0} + _ = [10]int{100: 0} // ERROR "index 100 out of bounds|out of range" + _ = [...]int{100: 0} + + _ = []int{t} // ERROR "cannot use .* as (type )?int( in slice literal)?|incompatible type" + _ = [10]int{t} // ERROR "cannot use .* as (type )?int( in array literal)?|incompatible type" + _ = [...]int{t} // ERROR "cannot use .* as (type )?int( in array literal)?|incompatible type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13415.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13415.go new file mode 100644 index 0000000000000000000000000000000000000000..cc17b8408615eb954a832dd2051a6482315ddd78 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13415.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2015 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. + +// Verify that error message regarding := appears on +// correct line (and not on the line of the 2nd :=). + +package p + +func f() { + select { + case x, x := <-func() chan int { // ERROR "x repeated on left side of :=|redefinition|declared and not used" + c := make(chan int) + return c + }(): + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13471.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13471.go new file mode 100644 index 0000000000000000000000000000000000000000..cab6bedee5a5f5c6ebf17f6a76261ee9d43f8e62 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13471.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2015 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. + +// Tests for golang.org/issue/13471 + +package main + +func main() { + const _ int64 = 1e646456992 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ int32 = 1e64645699 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ int16 = 1e6464569 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ int8 = 1e646456 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ int = 1e64645 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + + const _ uint64 = 1e646456992 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ uint32 = 1e64645699 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ uint16 = 1e6464569 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ uint8 = 1e646456 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + const _ uint = 1e64645 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" + + const _ rune = 1e64645 // ERROR "integer too large|floating-point constant truncated to integer|exponent too large|truncated" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13480.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13480.go new file mode 100644 index 0000000000000000000000000000000000000000..7e859c56c5d3d6f49617096bde837a2352530a44 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13480.go @@ -0,0 +1,38 @@ +// errorcheck + +// Copyright 2015 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. + +// Verify that comparisons of slice/map/func values against converted nil +// values are properly rejected. + +package p + +func bug() { + type S []byte + type M map[int]int + type F func() + + var s S + var m M + var f F + + _ = s == S(nil) // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + _ = S(nil) == s // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + switch s { + case S(nil): // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + } + + _ = m == M(nil) // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + _ = M(nil) == m // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + switch m { + case M(nil): // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + } + + _ = f == F(nil) // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + _ = F(nil) == f // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + switch f { + case F(nil): // ERROR "compare.*to nil|operator \=\= not defined for .|cannot compare" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13485.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13485.go new file mode 100644 index 0000000000000000000000000000000000000000..d928c1e1fa0efbe8ab954151f7a646794aa4e5e5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13485.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2010 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 p + +var ( + _ [10]int + _ [10.0]int + _ [float64(10)]int // ERROR "invalid array bound|must be integer" + _ [10 + 0i]int + _ [complex(10, 0)]int + _ [complex128(complex(10, 0))]int // ERROR "invalid array bound|must be integer" + _ ['a']int + _ [rune(65)]int +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13539.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13539.go new file mode 100644 index 0000000000000000000000000000000000000000..72c3ab0ae0ede61fb7fb1f095b251ff75c306c04 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13539.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2015 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. + +// Verify that a label named like a package is recognized +// as a label rather than a package and that the package +// remains unused. + +package main + +import "math" // ERROR "imported and not used" + +func main() { +math: + for { + break math + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13559.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13559.go new file mode 100644 index 0000000000000000000000000000000000000000..cc139d58d2658a594e9f4fe700d006bb075d31a9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13559.go @@ -0,0 +1,89 @@ +// errorcheck + +// Copyright 2015 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. + +// Verify that error messages print meaningful values +// for various extreme floating-point constants. + +package p + +// failure case in issue +const _ int64 = 1e-10000 // ERROR "1e\-10000 truncated|.* truncated to int64|truncated" + +const ( + _ int64 = 1e10000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1e1000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1e100000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1e10000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1e1000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1e100 // ERROR "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated" + _ int64 = 1e10 + _ int64 = 1e1 + _ int64 = 1e0 + _ int64 = 1e-1 // ERROR "0\.1 truncated|.* truncated to int64|truncated" + _ int64 = 1e-10 // ERROR "1e\-10 truncated|.* truncated to int64|truncated" + _ int64 = 1e-100 // ERROR "1e\-100 truncated|.* truncated to int64|truncated" + _ int64 = 1e-1000 // ERROR "1e\-1000 truncated|.* truncated to int64|truncated" + _ int64 = 1e-10000 // ERROR "1e\-10000 truncated|.* truncated to int64|truncated" + _ int64 = 1e-100000 // ERROR "1e\-100000 truncated|.* truncated to int64|truncated" + _ int64 = 1e-1000000 // ERROR "1e\-1000000 truncated|.* truncated to int64|truncated" +) + +const ( + _ int64 = -1e10000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1e1000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1e100000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1e10000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1e1000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1e100 // ERROR "\-10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated" + _ int64 = -1e10 + _ int64 = -1e1 + _ int64 = -1e0 + _ int64 = -1e-1 // ERROR "\-0\.1 truncated|.* truncated to int64|truncated" + _ int64 = -1e-10 // ERROR "\-1e\-10 truncated|.* truncated to int64|truncated" + _ int64 = -1e-100 // ERROR "\-1e\-100 truncated|.* truncated to int64|truncated" + _ int64 = -1e-1000 // ERROR "\-1e\-1000 truncated|.* truncated to int64|truncated" + _ int64 = -1e-10000 // ERROR "\-1e\-10000 truncated|.* truncated to int64|truncated" + _ int64 = -1e-100000 // ERROR "\-1e\-100000 truncated|.* truncated to int64|truncated" + _ int64 = -1e-1000000 // ERROR "\-1e\-1000000 truncated|.* truncated to int64|truncated" +) + +const ( + _ int64 = 1.23456789e10000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1.23456789e1000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1.23456789e100000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1.23456789e10000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1.23456789e1000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = 1.23456789e100 // ERROR "12345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated" + _ int64 = 1.23456789e10 + _ int64 = 1.23456789e1 // ERROR "12\.3457 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e0 // ERROR "1\.23457 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e-1 // ERROR "0\.123457 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e-10 // ERROR "1\.23457e\-10 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e-100 // ERROR "1\.23457e\-100 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e-1000 // ERROR "1\.23457e\-1000 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e-10000 // ERROR "1\.23457e\-10000 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e-100000 // ERROR "1\.23457e\-100000 truncated|.* truncated to int64|truncated" + _ int64 = 1.23456789e-1000000 // ERROR "1\.23457e\-1000000 truncated|.* truncated to int64|truncated" +) + +const ( + _ int64 = -1.23456789e10000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1.23456789e1000000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1.23456789e100000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1.23456789e10000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1.23456789e1000 // ERROR "integer too large|truncated to int64|truncated" + _ int64 = -1.23456789e100 // ERROR "\-12345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 overflows|truncated to int64|truncated" + _ int64 = -1.23456789e10 + _ int64 = -1.23456789e1 // ERROR "\-12\.3457 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e0 // ERROR "\-1\.23457 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e-1 // ERROR "\-0\.123457 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e-10 // ERROR "\-1\.23457e\-10 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e-100 // ERROR "\-1\.23457e\-100 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e-1000 // ERROR "\-1\.23457e\-1000 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e-10000 // ERROR "\-1\.23457e\-10000 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e-100000 // ERROR "\-1\.23457e\-100000 truncated|.* truncated to int64|truncated" + _ int64 = -1.23456789e-1000000 // ERROR "\-1\.23457e\-1000000 truncated|.* truncated to int64|truncated" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13587.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13587.go new file mode 100644 index 0000000000000000000000000000000000000000..b71bf9d7574d819a4d1a3ca53eaebfd7f5300a4a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13587.go @@ -0,0 +1,19 @@ +// errorcheck -0 -l -d=wb + +// Copyright 2015 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. + +// Test write barrier for implicit assignments to result parameters +// that have escaped to the heap. + +package issue13587 + +import "errors" + +func escape(p *error) + +func F() (err error) { + escape(&err) + return errors.New("error") // ERROR "write barrier" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13684.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13684.go new file mode 100644 index 0000000000000000000000000000000000000000..a1d88566e40ca68e991ccb7e7b417fd0117c64a0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13684.go @@ -0,0 +1,17 @@ +// run + +// Copyright 2015 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. + +// Verify that a label name matching a constant name +// is permitted. + +package main + +const labelname = 1 + +func main() { + goto labelname +labelname: +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13777.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13777.go new file mode 100644 index 0000000000000000000000000000000000000000..8f83c13ab9971661648833e4be23f47f3e86cad3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13777.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2015 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13779.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13779.go new file mode 100644 index 0000000000000000000000000000000000000000..b18577c152849675078f6f8a4833c75e3507235e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13779.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2016 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. + +// Issue 13779: provide better error message when directly assigning to struct field in map + +package main + +func main() { + type person struct{ age, weight, height int } + students := map[string]person{"sally": person{12, 50, 32}} + students["sally"].age = 3 // ERROR "cannot assign to struct field .* in map" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13799.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13799.go new file mode 100644 index 0000000000000000000000000000000000000000..f06f19829e78ea551b5ec131db9ea48bfcece5b9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13799.go @@ -0,0 +1,191 @@ +// errorcheck -0 -m -l + +// Copyright 2015 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. + +// Test, using compiler diagnostic flags, that the escape analysis is working. +// Compiles but does not run. Inlining is disabled. +// Registerization is disabled too (-N), which should +// have no effect on escape analysis. + +package main + +import "fmt" + +func main() { + // Just run test over and over again. This main func is just for + // convenience; if test were the main func, we could also trigger + // the panic just by running the program over and over again + // (sometimes it takes 1 time, sometimes it takes ~4,000+). + for iter := 0; ; iter++ { + if iter%50 == 0 { + fmt.Println(iter) // ERROR "iter escapes to heap$" "... argument does not escape$" + } + test1(iter) + test2(iter) + test3(iter) + test4(iter) + test5(iter) + test6(iter) + } +} + +func test1(iter int) { + + const maxI = 500 + m := make(map[int][]int) // ERROR "make\(map\[int\]\[\]int\) escapes to heap$" + + // The panic seems to be triggered when m is modified inside a + // closure that is both recursively called and reassigned to in a + // loop. + + // Cause of bug -- escape of closure failed to escape (shared) data structures + // of map. Assign to fn declared outside of loop triggers escape of closure. + // Heap -> stack pointer eventually causes badness when stack reallocation + // occurs. + + var fn func() // ERROR "moved to heap: fn$" + i := 0 // ERROR "moved to heap: i$" + for ; i < maxI; i++ { + // var fn func() // this makes it work, because fn stays off heap + j := 0 // ERROR "moved to heap: j$" + fn = func() { // ERROR "func literal escapes to heap$" + m[i] = append(m[i], 0) + if j < 25 { + j++ + fn() + } + } + fn() + } + + if len(m) != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, len(m) = %d", iter, maxI, len(m))) // ERROR "iter escapes to heap$" "len\(m\) escapes to heap$" "500 escapes to heap$" "... argument does not escape$" "fmt.Sprintf\(.*\) escapes to heap" + } +} + +func test2(iter int) { + + const maxI = 500 + m := make(map[int][]int) // ERROR "make\(map\[int\]\[\]int\) does not escape$" + + // var fn func() + for i := 0; i < maxI; i++ { + var fn func() // this makes it work, because fn stays off heap + j := 0 + fn = func() { // ERROR "func literal does not escape$" + m[i] = append(m[i], 0) + if j < 25 { + j++ + fn() + } + } + fn() + } + + if len(m) != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, len(m) = %d", iter, maxI, len(m))) // ERROR "iter escapes to heap$" "len\(m\) escapes to heap$" "500 escapes to heap$" "... argument does not escape$" "fmt.Sprintf\(.*\) escapes to heap" + } +} + +func test3(iter int) { + + const maxI = 500 + var x int // ERROR "moved to heap: x$" + m := &x + + var fn func() // ERROR "moved to heap: fn$" + for i := 0; i < maxI; i++ { + // var fn func() // this makes it work, because fn stays off heap + j := 0 // ERROR "moved to heap: j$" + fn = func() { // ERROR "func literal escapes to heap$" + if j < 100 { + j++ + fn() + } else { + *m = *m + 1 + } + } + fn() + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "500 escapes to heap$" "... argument does not escape$" "fmt.Sprintf\(.*\) escapes to heap" + } +} + +func test4(iter int) { + + const maxI = 500 + var x int + m := &x + + // var fn func() + for i := 0; i < maxI; i++ { + var fn func() // this makes it work, because fn stays off heap + j := 0 + fn = func() { // ERROR "func literal does not escape$" + if j < 100 { + j++ + fn() + } else { + *m = *m + 1 + } + } + fn() + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "500 escapes to heap$" "... argument does not escape$" "fmt.Sprintf\(.*\) escapes to heap" + } +} + +type str struct { + m *int +} + +func recur1(j int, s *str) { // ERROR "s does not escape" + if j < 100 { + j++ + recur1(j, s) + } else { + *s.m++ + } +} + +func test5(iter int) { + + const maxI = 500 + var x int // ERROR "moved to heap: x$" + m := &x + + var fn *str + for i := 0; i < maxI; i++ { + // var fn *str // this makes it work, because fn stays off heap + fn = &str{m} // ERROR "&str{...} escapes to heap" + recur1(0, fn) + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "500 escapes to heap$" "... argument does not escape$" "fmt.Sprintf\(.*\) escapes to heap" + } +} + +func test6(iter int) { + + const maxI = 500 + var x int + m := &x + + // var fn *str + for i := 0; i < maxI; i++ { + var fn *str // this makes it work, because fn stays off heap + fn = &str{m} // ERROR "&str{...} does not escape" + recur1(0, fn) + } + + if *m != maxI { + panic(fmt.Sprintf("iter %d: maxI = %d, *m = %d", iter, maxI, *m)) // ERROR "\*m escapes to heap$" "iter escapes to heap$" "500 escapes to heap$" "... argument does not escape$" "fmt.Sprintf\(.*\) escapes to heap" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13821.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13821.go new file mode 100644 index 0000000000000000000000000000000000000000..187e4b4cfb8bcb67a2266ef519801e073ff46829 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13821.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2015 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. + +// Issue 13821. Compiler rejected "bool(true)" as not a constant. + +package p + +const ( + A = true + B = bool(A) + C = bool(true) +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue13821b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue13821b.go new file mode 100644 index 0000000000000000000000000000000000000000..df68e8d6264c4be170aa9f458fae6f2b829611fb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue13821b.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2015 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. + +// Issue 13821. Additional regress tests. + +package p + +type B bool +type B2 bool + +var b B +var b2 B2 +var x1 = b && 1 < 2 // x1 has type B, not ideal bool +var x2 = 1 < 2 && b // x2 has type B, not ideal bool +var x3 = b && b2 // ERROR "mismatched types B and B2|incompatible types" +var x4 = x1 && b2 // ERROR "mismatched types B and B2|incompatible types" +var x5 = x2 && b2 // ERROR "mismatched types B and B2|incompatible types" +var x6 = b2 && x1 // ERROR "mismatched types B2 and B|incompatible types" +var x7 = b2 && x2 // ERROR "mismatched types B2 and B|incompatible types" + +var x8 = b && !B2(true) // ERROR "mismatched types B and B2|incompatible types" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14006.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14006.go new file mode 100644 index 0000000000000000000000000000000000000000..9cad2b4c9d127d2153043e693e59cce10bf08042 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14006.go @@ -0,0 +1,67 @@ +// errorcheck + +// Copyright 2016 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. + +// Literals that happen to resolve to named constants +// may be used as label names (see issue 13684). Make +// sure that other literals don't crash the compiler. + +package main + +const labelname = 1 + +func main() { + goto labelname +labelname: +} + +func f() { + var x int + switch x { + case 1: + 2: // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case 2: + } + + switch x { + case 1: + 2: ; // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case 2: + } + + var y string + switch y { + case "foo": + "bar": // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case "bar": + } + + switch y { + case "foo": + "bar": ; // ERROR "unexpected :|expected .*;.* or .*}.* or newline|value computed is not used" + case "bar": + } + + var z bool + switch { + case z: + labelname: // ERROR "missing statement after label" + case false: + } +} + +func g() { + var z bool + switch { + case z: + labelname: // ERROR "label labelname defined and not used|previous definition|defined and not used" + } + + switch { + case z: + labelname: ; // ERROR "label labelname already defined at LINE-5|label .*labelname.* already defined" + case false: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14010.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14010.go new file mode 100644 index 0000000000000000000000000000000000000000..0b233342be54a07b6418192363adee4562327a97 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14010.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2016 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. + +// Verify that built-in types don't get printed with +// (empty) package qualification. + +package main + +func main() { + true = false // ERROR "cannot assign to true|invalid left hand side" + byte = 0 // ERROR "not an expression|invalid left hand side|invalid use of type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14136.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14136.go new file mode 100644 index 0000000000000000000000000000000000000000..a066d2664ffcf9f3ebccd6aeab037f5c39fe45e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14136.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2016 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. + +// Test that > 10 non-syntax errors on the same line +// don't lead to early exit. Specifically, here test +// that we see the initialization error for variable +// s. + +package main + +type T struct{} + +func main() { + t := T{X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1, X: 1} // ERROR "unknown field 'X' in struct literal of type T|unknown field .*X.* in .*T.*" + _ = t + var s string = 1 // ERROR "cannot use 1|incompatible type|cannot convert" + _ = s +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14164.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14164.go new file mode 100644 index 0000000000000000000000000000000000000000..5247599d497baf21f6e17ac75df9520f18fb6d6e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14164.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2016 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. + +ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14321.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14321.go new file mode 100644 index 0000000000000000000000000000000000000000..0791819907411433a7f15f6a9c3b6f3f4a24baa7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14321.go @@ -0,0 +1,33 @@ +// errorcheck + +// Copyright 2018 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. + +// Verify that error message reports _ambiguous_ method. + +package p + +type A struct{ + H int +} + +func (A) F() {} +func (A) G() {} + +type B struct{ + G int + H int +} + +func (B) F() {} + +type C struct { + A + B +} + +var _ = C.F // ERROR "ambiguous" +var _ = C.G // ERROR "ambiguous" +var _ = C.H // ERROR "ambiguous" +var _ = C.I // ERROR "no method .*I.*|C.I undefined" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14331.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14331.go new file mode 100644 index 0000000000000000000000000000000000000000..b8ee2fb14b7ca6f1447c272f2eca22b5964c72be --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14331.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2016 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. + +// Inline function misses struct tags. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14405.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14405.go new file mode 100644 index 0000000000000000000000000000000000000000..94592fd18b8556587206c9138c004e7d6d2273cc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14405.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 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. + +// Mention of field with large offset in struct literal causes crash +package p + +type T struct { + Slice [1 << 20][]int + Ptr *int +} + +func New(p *int) *T { + return &T{Ptr: p} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14520.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14520.go new file mode 100644 index 0000000000000000000000000000000000000000..29cc270deb070b83c05a3ec66f9cb77ba82d0dc9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14520.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2016 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 f + +func f(x int /* // GC_ERROR "unexpected newline" + +*/) // GCCGO_ERROR "expected .*\).*|expected declaration" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14520a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14520a.go new file mode 100644 index 0000000000000000000000000000000000000000..bb45d7e186de3fda60cbf9e0833c3c97d8c940d9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14520a.go @@ -0,0 +1,10 @@ +// errorcheck + +// Copyright 2016 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 f + +import /* // ERROR "import path" */ ` +bogus` diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14540.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14540.go new file mode 100644 index 0000000000000000000000000000000000000000..62b17a04c482e47bdd6640285c542f120a8cffd2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14540.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 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 p + +func f(x int) { + switch x { + case 0: + fallthrough + ; // ok + case 1: + fallthrough // ERROR "fallthrough statement out of place" + {} + case 2: + fallthrough // ERROR "cannot fallthrough" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14553.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14553.go new file mode 100644 index 0000000000000000000000000000000000000000..d7ebb1288eb820cce4d777e6d57af66b51301f52 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14553.go @@ -0,0 +1,45 @@ +// run + +// Copyright 2016 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. + +// This test checks if the compiler's internal constant +// arithmetic correctly rounds denormal float32 values. + +package main + +import ( + "fmt" + "math" +) + +func main() { + for _, t := range []struct { + value float32 + bits uint32 + }{ + {0e+00, 0x00000000}, + {1e-46, 0x00000000}, + {0.5e-45, 0x00000000}, + {0.8e-45, 0x00000001}, + {1e-45, 0x00000001}, + {2e-45, 0x00000001}, + {3e-45, 0x00000002}, + {4e-45, 0x00000003}, + {5e-45, 0x00000004}, + {6e-45, 0x00000004}, + {7e-45, 0x00000005}, + {8e-45, 0x00000006}, + {9e-45, 0x00000006}, + {1.0e-44, 0x00000007}, + {1.1e-44, 0x00000008}, + {1.2e-44, 0x00000009}, + } { + got := math.Float32bits(t.value) + want := t.bits + if got != want { + panic(fmt.Sprintf("bits(%g) = 0x%08x; want 0x%08x", t.value, got, want)) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14591.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14591.go new file mode 100644 index 0000000000000000000000000000000000000000..626fbbcac48374e53e26014d52f85a87377eba76 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14591.go @@ -0,0 +1,38 @@ +// run + +// Copyright 2016 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. + +// Test to make sure we don't think values are dead +// when they are assigned to a PPARAMOUT slot before +// the last GC safepoint. + +package main + +import ( + "fmt" + "runtime" +) + +// When a T is deallocated, T[1] is certain to +// get clobbered (the runtime writes 0xdeaddeaddeaddead there). +type T [4]int + +func f() (r, s *T) { + r = &T{0x30, 0x31, 0x32, 0x33} + runtime.GC() + s = &T{0x40, 0x41, 0x42, 0x43} + runtime.GC() + return +} + +func main() { + r, s := f() + if r[1] != 0x31 { + fmt.Printf("bad r[1], want 0x31 got %x\n", r[1]) + } + if s[1] != 0x41 { + fmt.Printf("bad s[1], want 0x41 got %x\n", s[1]) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14636.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14636.go new file mode 100644 index 0000000000000000000000000000000000000000..c8e751fb613c2e8120201dc3bd2c7bdd67b24e66 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14636.go @@ -0,0 +1,44 @@ +// run + +//go:build !nacl && !js && !wasip1 && !android && gc + +// Copyright 2016 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 + +import ( + "bytes" + "log" + "os/exec" + "strings" +) + +func main() { + checkLinkOutput("", "-B argument must start with 0x") + checkLinkOutput("0", "-B argument must start with 0x") + checkLinkOutput("0x", "usage") + checkLinkOutput("0x0", "-B argument must have even number of digits") + checkLinkOutput("0x00", "usage") + checkLinkOutput("0xYZ", "-B argument contains invalid hex digit") + checkLinkOutput("0x"+strings.Repeat("00", 32), "usage") + checkLinkOutput("0x"+strings.Repeat("00", 33), "-B option too long (max 32 digits)") +} + +func checkLinkOutput(buildid string, message string) { + cmd := exec.Command("go", "tool", "link", "-B", buildid) + out, err := cmd.CombinedOutput() + if err == nil { + log.Fatalf("expected cmd/link to fail") + } + + firstLine := string(bytes.SplitN(out, []byte("\n"), 2)[0]) + if strings.HasPrefix(firstLine, "panic") { + log.Fatalf("cmd/link panicked:\n%s", out) + } + + if !strings.Contains(firstLine, message) { + log.Fatalf("cmd/link output did not include expected message %q: %s", message, firstLine) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14646.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14646.go new file mode 100644 index 0000000000000000000000000000000000000000..96a685464faa081a9e6ab61fa1c64c1894c968f9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14646.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2016 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 + +import "runtime" + +func main() { + var file string + var line int + func() { + defer func() { + _, file, line, _ = runtime.Caller(1) + }() + }() // this is the expected line + const EXPECTED = 18 + if line != EXPECTED { + println("Expected line =", EXPECTED, "but got line =", line, "and file =", file) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14651.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14651.go new file mode 100644 index 0000000000000000000000000000000000000000..4c756e502e25f6d58931a2fc0e8841b4b02456ca --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14651.go @@ -0,0 +1,71 @@ +// run + +// Copyright 2016 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. + +// This test checks if the compiler's internal constant +// arithmetic correctly rounds up floating-point values +// that become the smallest denormal value. +// +// See also related issue 14553 and test issue14553.go. + +package main + +import ( + "fmt" + "math" +) + +const ( + p149 = 1.0 / (1 << 149) // 1p-149 + p500 = 1.0 / (1 << 500) // 1p-500 + p1074 = p500 * p500 / (1<<74) // 1p-1074 +) + +const ( + m0000p149 = 0x0 / 16.0 * p149 // = 0.0000p-149 + m1000p149 = 0x8 / 16.0 * p149 // = 0.1000p-149 + m1001p149 = 0x9 / 16.0 * p149 // = 0.1001p-149 + m1011p149 = 0xb / 16.0 * p149 // = 0.1011p-149 + m1100p149 = 0xc / 16.0 * p149 // = 0.1100p-149 + + m0000p1074 = 0x0 / 16.0 * p1074 // = 0.0000p-1074 + m1000p1074 = 0x8 / 16.0 * p1074 // = 0.1000p-1074 + m1001p1074 = 0x9 / 16.0 * p1074 // = 0.1001p-1074 + m1011p1074 = 0xb / 16.0 * p1074 // = 0.1011p-1074 + m1100p1074 = 0xc / 16.0 * p1074 // = 0.1100p-1074 +) + +func main() { + test32(float32(m0000p149), f32(m0000p149)) + test32(float32(m1000p149), f32(m1000p149)) + test32(float32(m1001p149), f32(m1001p149)) + test32(float32(m1011p149), f32(m1011p149)) + test32(float32(m1100p149), f32(m1100p149)) + + test64(float64(m0000p1074), f64(m0000p1074)) + test64(float64(m1000p1074), f64(m1000p1074)) + test64(float64(m1001p1074), f64(m1001p1074)) + test64(float64(m1011p1074), f64(m1011p1074)) + test64(float64(m1100p1074), f64(m1100p1074)) +} + +func f32(x float64) float32 { return float32(x) } +func f64(x float64) float64 { return float64(x) } + +func test32(a, b float32) { + abits := math.Float32bits(a) + bbits := math.Float32bits(b) + if abits != bbits { + panic(fmt.Sprintf("%08x != %08x\n", abits, bbits)) + } +} + +func test64(a, b float64) { + abits := math.Float64bits(a) + bbits := math.Float64bits(b) + if abits != bbits { + panic(fmt.Sprintf("%016x != %016x\n", abits, bbits)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14652.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14652.go new file mode 100644 index 0000000000000000000000000000000000000000..586663b676fd9c26abb18b2c4c0b8ccc226db9ae --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14652.go @@ -0,0 +1,10 @@ +// compile + +// Copyright 2016 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 p + +// any is now permitted instead of interface{} +var x any diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14725.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14725.go new file mode 100644 index 0000000000000000000000000000000000000000..49f3fbcf417c43d4cc53ed94967e6d7e3742d050 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14725.go @@ -0,0 +1,57 @@ +// run + +// Copyright 2016 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 + +import "fmt" + +func f1() (x int) { + for { + defer func() { + recover() + x = 1 + }() + panic(nil) + } +} + +var sink *int + +func f2() (x int) { + sink = &x + defer func() { + recover() + x = 1 + }() + panic(nil) +} + +func f3(b bool) (x int) { + sink = &x + defer func() { + recover() + x = 1 + }() + if b { + panic(nil) + } + return +} + +func main() { + if x := f1(); x != 1 { + panic(fmt.Sprintf("f1 returned %d, wanted 1", x)) + } + if x := f2(); x != 1 { + panic(fmt.Sprintf("f2 returned %d, wanted 1", x)) + } + if x := f3(true); x != 1 { + panic(fmt.Sprintf("f3(true) returned %d, wanted 1", x)) + } + if x := f3(false); x != 1 { + panic(fmt.Sprintf("f3(false) returned %d, wanted 1", x)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14729.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14729.go new file mode 100644 index 0000000000000000000000000000000000000000..e5c8235849b96e2715a6cb41ed6c9b415421e3fa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14729.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2016 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. + +// Issue 14729: structs cannot embed unsafe.Pointer per the spec. + +package main + +import "unsafe" + +type s struct { unsafe.Pointer } // ERROR "embedded type cannot be a pointer|embedded type may not be a pointer||embedded field type cannot be unsafe.Pointer" +type s1 struct { p unsafe.Pointer } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14988.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14988.go new file mode 100644 index 0000000000000000000000000000000000000000..4ddc7e728f903b5e3b920c2c1ad58f1adaa5d5fe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14988.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2016 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. + +// Issue 14988: defining a map with an invalid forward declaration array +// key doesn't cause a fatal. + +package main + +type m map[k]int // ERROR "invalid map key type" +type k [1]m diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue14999.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue14999.go new file mode 100644 index 0000000000000000000000000000000000000000..a25a50e519a5ea75d90fd263ac11328b3aef09eb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue14999.go @@ -0,0 +1,18 @@ +// errorcheck -+ + +// Copyright 2016 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 p + +func f(x int) func(int) int { + return func(y int) int { return x + y } // ERROR "heap-allocated closure f\.func1, not allowed in runtime" +} + +func g(x int) func(int) int { // ERROR "x escapes to heap, not allowed in runtime" + return func(y int) int { // ERROR "heap-allocated closure g\.func1, not allowed in runtime" + x += y + return x + y + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15002.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15002.go new file mode 100644 index 0000000000000000000000000000000000000000..bb0fe424069870bf19b380db00d57edb6777cce2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15002.go @@ -0,0 +1,132 @@ +// run + +//go:build amd64 && (linux || darwin) + +// Copyright 2016 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 + +import ( + "fmt" + "syscall" +) + +// Use global variables so the compiler +// doesn't know that they are constants. +var p = syscall.Getpagesize() +var zero = 0 +var one = 1 + +func main() { + // Allocate 2 pages of memory. + b, err := syscall.Mmap(-1, 0, 2*p, syscall.PROT_READ|syscall.PROT_WRITE, syscall.MAP_ANON|syscall.MAP_PRIVATE) + if err != nil { + panic(err) + } + // Mark the second page as faulting. + err = syscall.Mprotect(b[p:], syscall.PROT_NONE) + if err != nil { + panic(err) + } + // Get a slice pointing to the last byte of the good page. + x := b[p-one : p] + + test16(x) + test16i(x, 0) + test32(x) + test32i(x, 0) + test64(x) + test64i(x, 0) +} + +func test16(x []byte) uint16 { + defer func() { + r := recover() + if r == nil { + panic("no fault or bounds check failure happened") + } + s := fmt.Sprintf("%s", r) + if s != "runtime error: index out of range [1] with length 1" { + panic("bad panic: " + s) + } + }() + // Try to read 2 bytes from x. + return uint16(x[0]) | uint16(x[1])<<8 + + // We expect to get an "index out of range" error from x[1]. + // If we promote the first load to a 2-byte load, it will segfault, which we don't want. +} + +func test16i(x []byte, i int) uint16 { + defer func() { + r := recover() + if r == nil { + panic("no fault or bounds check failure happened") + } + s := fmt.Sprintf("%s", r) + if s != "runtime error: index out of range [1] with length 1" { + panic("bad panic: " + s) + } + }() + return uint16(x[i]) | uint16(x[i+1])<<8 +} + +func test32(x []byte) uint32 { + defer func() { + r := recover() + if r == nil { + panic("no fault or bounds check failure happened") + } + s := fmt.Sprintf("%s", r) + if s != "runtime error: index out of range [1] with length 1" { + panic("bad panic: " + s) + } + }() + return uint32(x[0]) | uint32(x[1])<<8 | uint32(x[2])<<16 | uint32(x[3])<<24 +} + +func test32i(x []byte, i int) uint32 { + defer func() { + r := recover() + if r == nil { + panic("no fault or bounds check failure happened") + } + s := fmt.Sprintf("%s", r) + if s != "runtime error: index out of range [1] with length 1" { + panic("bad panic: " + s) + } + }() + return uint32(x[i]) | uint32(x[i+1])<<8 | uint32(x[i+2])<<16 | uint32(x[i+3])<<24 +} + +func test64(x []byte) uint64 { + defer func() { + r := recover() + if r == nil { + panic("no fault or bounds check failure happened") + } + s := fmt.Sprintf("%s", r) + if s != "runtime error: index out of range [1] with length 1" { + panic("bad panic: " + s) + } + }() + return uint64(x[0]) | uint64(x[1])<<8 | uint64(x[2])<<16 | uint64(x[3])<<24 | + uint64(x[4])<<32 | uint64(x[5])<<40 | uint64(x[6])<<48 | uint64(x[7])<<56 +} + +func test64i(x []byte, i int) uint64 { + defer func() { + r := recover() + if r == nil { + panic("no fault or bounds check failure happened") + } + s := fmt.Sprintf("%s", r) + if s != "runtime error: index out of range [1] with length 1" { + panic("bad panic: " + s) + } + }() + return uint64(x[i+0]) | uint64(x[i+1])<<8 | uint64(x[i+2])<<16 | uint64(x[i+3])<<24 | + uint64(x[i+4])<<32 | uint64(x[i+5])<<40 | uint64(x[i+6])<<48 | uint64(x[i+7])<<56 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15013.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15013.go new file mode 100644 index 0000000000000000000000000000000000000000..9e218e6d81026f53d4a9869c0c7a847c39386cfc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15013.go @@ -0,0 +1,24 @@ +// compile + +// Copyright 2016 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. + +// CL 21202 introduced a compiler crash in the handling of a varargs +// function in the same recursive group as a function that calls it. +// Nothing in the standard library caught the problem, so adding a test. + +package p + +func F1(p *int, a ...*int) (int, *int) { + if p == nil { + return F2(), a[0] + } + return 0, a[0] +} + +func F2() int { + var i0, i1 int + a, _ := F1(&i0, &i1) + return a +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15039.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15039.go new file mode 100644 index 0000000000000000000000000000000000000000..85d9e8340aa1349a16719b5f628c1b14f16a1081 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15039.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2016 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 main() { + const fffd = "\uFFFD" + + // runtime.intstring used to convert int64 to rune without checking + // for truncation. + u := uint64(0x10001f4a9) + big := string(u) + if big != fffd { + panic("big != bad") + } + + // cmd/compile used to require integer constants to fit into an "int". + const huge = string(1<<100) + if huge != fffd { + panic("huge != bad") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15042.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15042.go new file mode 100644 index 0000000000000000000000000000000000000000..85d5d6c361a061d85f4d6568c15c8a4683abaaae --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15042.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2016 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. + +// Exchanging two struct fields was compiled incorrectly. + +package main + +type S struct { + i int +} + +func F(c bool, s1, s2 S) (int, int) { + if c { + s1.i, s2.i = s2.i, s1.i + } + return s1.i, s2.i +} + +func main() { + i, j := F(true, S{1}, S{20}) + if i != 20 || j != 1 { + panic(i+j) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15055.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15055.go new file mode 100644 index 0000000000000000000000000000000000000000..81758d141c8305370e3c99863a52d052a319298d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15055.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2016 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 main() { + type name string + _ = []byte("abc", "def", 12) // ERROR "too many arguments (to conversion to \[\]byte: \(\[\]byte\)\(.abc., .def., 12\))?" + _ = string("a", "b", nil) // ERROR "too many arguments (to conversion to string: string\(.a., .b., nil\))?" + _ = []byte() // ERROR "missing argument (to conversion to \[\]byte: \(\[\]byte\)\(\))?" + _ = string() // ERROR "missing argument (to conversion to string: string\(\))?" + _ = *int() // ERROR "missing argument (to conversion to int: int\(\))?" + _ = (*int)() // ERROR "missing argument (to conversion to \*int: \(\*int\)\(\))?" + _ = name("a", 1, 3.3) // ERROR "too many arguments (to conversion to name: name\(.a., 1, 3.3\))?" + _ = map[string]string(nil, nil) // ERROR "too many arguments (to conversion to map\[string\]string: \(map\[string\]string\)\(nil, nil\))?" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15071.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15071.go new file mode 100644 index 0000000000000000000000000000000000000000..af6f1341729458e04aba9a8a7110ec999540bc2a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15071.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15084.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15084.go new file mode 100644 index 0000000000000000000000000000000000000000..7eb294e6a669184207f0a0fb74ff20c7562e93f9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15084.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2016 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 x + +type T struct { + i int + e interface{} +} + +func (t *T) F() bool { + if t.i != 0 { + return false + } + _, ok := t.e.(string) + return ok +} + +var x int + +func g(t *T) { + if t.F() || true { + if t.F() { + x = 0 + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15091.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15091.go new file mode 100644 index 0000000000000000000000000000000000000000..115ad6840fd4e1ffe8fcc5e2ecec75f53586d2aa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15091.go @@ -0,0 +1,27 @@ +// errorcheck -0 -race + +//go:build (linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64) + +// Copyright 2016 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 sample + +type Html struct { + headerIDs map[string]int +} + +// We don't want to see: +// internal error: (*Html).xyzzy autotmp_3 (type *int) recorded as live on entry, p.Pc=0 +// or (now, with the error caught earlier) +// Treating auto as if it were arg, func (*Html).xyzzy, node ... +// caused by racewalker inserting instrumentation before an OAS where the Ninit +// of the OAS defines part of its right-hand-side. (I.e., the race instrumentation +// references a variable before it is defined.) +func (options *Html) xyzzy(id string) string { + for count, found := options.headerIDs[id]; found; count, found = options.headerIDs[id] { + _ = count + } + return "" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15141.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15141.go new file mode 100644 index 0000000000000000000000000000000000000000..752f530273c8eb9bc989d293fa4b63f8e3d7cb63 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15141.go @@ -0,0 +1,33 @@ +// compile + +// Copyright 2016 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 main() { + a := f(1, 99) + b := g(0xFFFFFFe, 98) + c := h(0xFFFFFFe, 98) + println(a[1], b[1], c[1], a[0xFFFFFFe], b[0xFFFFFFe], c[0xFFFFFFe]) +} + +//go:noinline +func f(i, y int) (a [0xFFFFFFF]byte) { + a[i] = byte(y) + return +} + +//go:noinline +func g(i, y int) [0xFFFFFFF]byte { + var a [0xFFFFFFF]byte + a[i] = byte(y) + return a +} + +//go:noinline +func h(i, y int) (a [0xFFFFFFF]byte) { + a[i] = byte(y) + return a +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15175.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15175.go new file mode 100644 index 0000000000000000000000000000000000000000..55a8f7d65ab394c94e66d387019ea75b073244bd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15175.go @@ -0,0 +1,66 @@ +// run + +// Copyright 2016 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. + +// Make sure unsigned shift results get sign-extended correctly. +package main + +import "fmt" + +func main() { + failed := false + a6 := uint8(253) + if got := a6 >> 0; got != 253 { + fmt.Printf("uint8(253)>>0 = %v, wanted 253\n", got) + failed = true + } + if got := f1(0, 2, 1, 0, 0, 1, true); got != 255 { + fmt.Printf("f1(...) = %v, wanted 255\n", got) + failed = true + } + if got := f2(1); got != 242 { + fmt.Printf("f2(...) = %v, wanted 242\n", got) + failed = true + } + if got := f3(false, 0, 0); got != 254 { + fmt.Printf("f3(...) = %v, wanted 254\n", got) + failed = true + } + if failed { + panic("bad") + } +} + +func f1(a1 uint, a2 int8, a3 int8, a4 int8, a5 uint8, a6 int, a7 bool) uint8 { + a5-- + a4 += (a2 << a1 << 2) | (a4 ^ a4<<(a1&a1)) - a3 // int8 + a6 -= a6 >> (2 + uint32(a2)>>3) // int + a1 += a1 // uint + a3 *= a4 << (a1 | a1) << (uint16(3) >> 2 & (1 - 0) & (uint16(1) << a5 << 3)) // int8 + a7 = a7 || ((a2 == a4) || (a7 && a7) || ((a5 == a5) || (a7 || a7))) // bool + return a5 >> a1 +} + +func f2(a1 uint8) uint8 { + a1-- + a1-- + a1 -= a1 + (a1 << 1) - (a1*a1*a1)<<(2-0+(3|3)-1) // uint8 + v1 := 0 * ((2 * 1) ^ 1) & ((uint(0) >> a1) + (2+0)*(uint(2)+0)) // uint + _ = v1 + return a1 >> (((2 ^ 2) >> (v1 | 2)) + 0) +} + +func f3(a1 bool, a2 uint, a3 int64) uint8 { + a3-- + v1 := 1 & (2 & 1 * (1 ^ 2) & (uint8(3*1) >> 0)) // uint8 + _ = v1 + v1 += v1 - (v1 >> a2) + (v1 << (a2 ^ a2) & v1) // uint8 + v1 *= v1 // uint8 + a3-- + v1 += v1 & v1 // uint8 + v1-- + v1 = ((v1 << 0) | v1>>0) + v1 // uint8 + return v1 >> 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15252.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15252.go new file mode 100644 index 0000000000000000000000000000000000000000..370a885c7f514abd8c26afcc481c28b02084353b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15252.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2016 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. + +// This test makes sure that we use all 64 bits of an +// index, even on 32 bit machines. It also tests that nacl +// can compile 64 bit indexes loaded from ODOTPTR properly. + +package main + +type T struct { + i int64 +} + +func f(t *T) byte { + b := [2]byte{3, 4} + return b[t.i] +} + +func main() { + t := &T{0x100000001} + defer func() { + r := recover() + if r == nil { + panic("panic wasn't recoverable") + } + }() + f(t) + panic("index didn't panic") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15277.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15277.go new file mode 100644 index 0000000000000000000000000000000000000000..d22a305b0b53fb67af70b43f7d2e27d9ff40dafc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15277.go @@ -0,0 +1,41 @@ +// run + +//go:build amd64 + +// Copyright 2016 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 + +import "runtime" + +type big [10 << 20]byte + +func f(x *big, start int64) { + if delta := inuse() - start; delta < 9<<20 { + println("after alloc: expected delta at least 9MB, got: ", delta) + } + runtime.KeepAlive(x) + x = nil + if delta := inuse() - start; delta > 1<<20 { + println("after drop: expected delta below 1MB, got: ", delta) + } + x = new(big) + if delta := inuse() - start; delta < 9<<20 { + println("second alloc: expected delta at least 9MB, got: ", delta) + } + runtime.KeepAlive(x) +} + +func main() { + x := inuse() + f(new(big), x) +} + +func inuse() int64 { + runtime.GC() + var st runtime.MemStats + runtime.ReadMemStats(&st) + return int64(st.Alloc) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15281.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15281.go new file mode 100644 index 0000000000000000000000000000000000000000..390867c84835b0691ceff9fe910b8058268832d9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15281.go @@ -0,0 +1,65 @@ +// run + +// Copyright 2016 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 + +import "runtime" + +func main() { + { + x := inuse() + c := make(chan []byte, 10) + c <- make([]byte, 10<<20) + close(c) + f1(c, x) + } + { + x := inuse() + c := make(chan []byte, 10) + c <- make([]byte, 10<<20) + close(c) + f2(c, x) + } +} + +func f1(c chan []byte, start int64) { + for x := range c { + if delta := inuse() - start; delta < 9<<20 { + println("BUG: f1: after alloc: expected delta at least 9MB, got: ", delta) + println(x) + } + x = nil + if delta := inuse() - start; delta > 1<<20 { + println("BUG: f1: after alloc: expected delta below 1MB, got: ", delta) + println(x) + } + } +} + +func f2(c chan []byte, start int64) { + for { + x, ok := <-c + if !ok { + break + } + if delta := inuse() - start; delta < 9<<20 { + println("BUG: f2: after alloc: expected delta at least 9MB, got: ", delta) + println(x) + } + x = nil + if delta := inuse() - start; delta > 1<<20 { + println("BUG: f2: after alloc: expected delta below 1MB, got: ", delta) + println(x) + } + } +} + +func inuse() int64 { + runtime.GC() + var st runtime.MemStats + runtime.ReadMemStats(&st) + return int64(st.Alloc) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15303.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15303.go new file mode 100644 index 0000000000000000000000000000000000000000..c8dfa30dfbfc6912fb8eb39a6402d90f097a314a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15303.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2016 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. + +// Ensure that inlined struct/array comparisons have the right side-effects. + +package main + +import "os" + +func main() { + var x int + f := func() (r [4]int) { + x++ + return + } + _ = f() == f() + if x != 2 { + println("f evaluated ", x, " times, want 2") + os.Exit(1) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15311.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15311.go new file mode 100644 index 0000000000000000000000000000000000000000..81fa54132574ceda3481b6dbab8288f6b57695a6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15311.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2016 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. + +// The compiler was failing to correctly report an error when a dot +// expression was used a struct literal key. + +package p + +type T struct { + toInt map[string]int + toString map[int]string +} + +var t = T{ + foo.toInt: make(map[string]int), // ERROR "field name" + bar.toString: make(map[int]string), // ERROR "field name" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15329.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15329.go new file mode 100644 index 0000000000000000000000000000000000000000..30fbf1379706515361b68919068c6d3b7a86e739 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15329.go @@ -0,0 +1,79 @@ +// run + +// Copyright 2016 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. + +// Previously, cmd/compile would rewrite +// +// check(unsafe.Pointer(testMeth(1).Pointer()), unsafe.Pointer(testMeth(2).Pointer())) +// +// to +// +// var autotmp_1 uintptr = testMeth(1).Pointer() +// var autotmp_2 uintptr = testMeth(2).Pointer() +// check(unsafe.Pointer(autotmp_1), unsafe.Pointer(autotmp_2)) +// +// However, that means autotmp_1 is the only reference to the int +// variable containing the value "1", but it's not a pointer type, +// so it was at risk of being garbage collected by the evaluation of +// testMeth(2).Pointer(), even though package unsafe's documentation +// says the original code was allowed. +// +// Now cmd/compile rewrites it to +// +// var autotmp_1 unsafe.Pointer = unsafe.Pointer(testMeth(1).Pointer()) +// var autotmp_2 unsafe.Pointer = unsafe.Pointer(testMeth(2).Pointer()) +// check(autotmp_1, autotmp_2) +// +// to ensure the pointed-to variables are visible to the GC. + +package main + +import ( + "fmt" + "reflect" + "runtime" + "unsafe" +) + +func main() { + // Test all the different ways we can invoke reflect.Value.Pointer. + + // Direct method invocation. + check(unsafe.Pointer(testMeth(1).Pointer()), unsafe.Pointer(testMeth(2).Pointer())) + + // Invocation via method expression. + check(unsafe.Pointer(reflect.Value.Pointer(testMeth(1))), unsafe.Pointer(reflect.Value.Pointer(testMeth(2)))) + + // Invocation via interface. + check(unsafe.Pointer(testInter(1).Pointer()), unsafe.Pointer(testInter(2).Pointer())) + + // Invocation via method value. + check(unsafe.Pointer(testFunc(1)()), unsafe.Pointer(testFunc(2)())) +} + +func check(p, q unsafe.Pointer) { + a, b := *(*int)(p), *(*int)(q) + if a != 1 || b != 2 { + fmt.Printf("got %v, %v; expected 1, 2\n", a, b) + } +} + +func testMeth(x int) reflect.Value { + // Force GC to run. + runtime.GC() + return reflect.ValueOf(&x) +} + +type Pointerer interface { + Pointer() uintptr +} + +func testInter(x int) Pointerer { + return testMeth(x) +} + +func testFunc(x int) func() uintptr { + return testMeth(x).Pointer +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15439.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15439.go new file mode 100644 index 0000000000000000000000000000000000000000..840a3c02a8b43668cf8ae5a78e15bf72365c1f11 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15439.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2016 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 + +import "reflect" + +func main() { + a := &struct{ x int }{} + b := &struct{ x int "" }{} + + ta := reflect.TypeOf(a) + tb := reflect.TypeOf(b) + + // Ensure cmd/compile treats absent and empty tags as equivalent. + a = b + + // Ensure package reflect treats absent and empty tags as equivalent. + if !tb.AssignableTo(ta) { + panic("fail") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15470.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15470.go new file mode 100644 index 0000000000000000000000000000000000000000..22b48fe257351361bc6df020a133cee0c4159c50 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15470.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2016 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. + +// Issue 15470: Make sure special-case signatures can +// be exported and imported w/o problems. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15514.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15514.go new file mode 100644 index 0000000000000000000000000000000000000000..626f7ad699e659c877c3dcdce051869b60c5161b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15514.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2016 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15528.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15528.go new file mode 100644 index 0000000000000000000000000000000000000000..b1f9dfbb5cc8ac621165af48e04488e72a239cd8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15528.go @@ -0,0 +1,131 @@ +// run + +// Copyright 2016 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 + +import ( + "fmt" + "io" + "os" + "reflect" + "unsafe" +) + +type RWS struct{} + +func (x *RWS) Read(p []byte) (n int, err error) { return } +func (x *RWS) Write(p []byte) (n int, err error) { return } +func (x *RWS) Seek(offset int64, whence int) (n int64, err error) { return } +func (x *RWS) String() string { return "rws" } + +func makeRWS() io.ReadWriteSeeker { return &RWS{} } +func makeStringer() fmt.Stringer { return &RWS{} } + +// Test correct construction of static empty interface values +var efaces = [...]struct { + x interface{} + s string +}{ + {nil, " "}, + {1, "int 1"}, + {int(1), "int 1"}, + {Int(int(2)), "main.Int Int=2"}, + {int(Int(3)), "int 3"}, + {[1]int{2}, "[1]int [2]"}, + {io.Reader(io.ReadWriter(io.ReadWriteSeeker(nil))), " "}, + {io.Reader(io.ReadWriter(io.ReadWriteSeeker(&RWS{}))), "*main.RWS rws"}, + {makeRWS(), "*main.RWS rws"}, + {map[string]string{"here": "there"}, "map[string]string map[here:there]"}, + {chan bool(nil), "chan bool "}, + {unsafe.Pointer(uintptr(0)), "unsafe.Pointer "}, + {(*byte)(nil), "*uint8 "}, + {io.Writer((*os.File)(nil)), "*os.File "}, + {(interface{})(io.Writer((*os.File)(nil))), "*os.File "}, + {fmt.Stringer(Strunger(((*Int)(nil)))), "*main.Int "}, +} + +type Int int + +func (i Int) String() string { return fmt.Sprintf("Int=%d", i) } +func (i Int) Strung() {} + +type Strunger interface { + fmt.Stringer + Strung() +} + +// Test correct construction of static non-empty interface values +var ifaces = [...]struct { + x fmt.Stringer + s string +}{ + {nil, " %!s()"}, + {Int(3), "main.Int 3 Int=3"}, + {Int(int(Int(4))), "main.Int 4 Int=4"}, + {Strunger(Int(5)), "main.Int 5 Int=5"}, + {makeStringer(), "*main.RWS &main.RWS{} rws"}, + {fmt.Stringer(nil), " %!s()"}, + {(*RWS)(nil), "*main.RWS (*main.RWS)(nil) rws"}, +} + +// Test correct handling of direct interface values +var ( + one int = 1 + iptr interface{} = &one + clos int + f interface{} = func() { clos++ } + deep interface{} = [1]struct{ a *[2]byte }{{a: &[2]byte{'z', 'w'}}} + ch interface{} = make(chan bool, 1) +) + +func main() { + var fail bool + for i, test := range efaces { + s := fmt.Sprintf("%[1]T %[1]v", test.x) + if s != test.s { + fmt.Printf("eface(%d)=%q want %q\n", i, s, test.s) + fail = true + } + } + + for i, test := range ifaces { + s := fmt.Sprintf("%[1]T %#[1]v %[1]s", test.x) + if s != test.s { + fmt.Printf("iface(%d)=%q want %q\n", i, s, test.s) + fail = true + } + } + + if got := *(iptr.(*int)); got != 1 { + fmt.Printf("bad int ptr %d\n", got) + fail = true + } + + f.(func())() + f.(func())() + f.(func())() + if clos != 3 { + fmt.Printf("bad closure exec %d\n", clos) + fail = true + } + + if !reflect.DeepEqual(*(deep.([1]struct{ a *[2]byte })[0].a), [2]byte{'z', 'w'}) { + fmt.Printf("bad deep directiface\n") + fail = true + } + + cc := ch.(chan bool) + cc <- true + if got := <-cc; !got { + fmt.Printf("bad chan\n") + fail = true + } + + if fail { + fmt.Println("BUG") + os.Exit(1) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15548.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15548.go new file mode 100644 index 0000000000000000000000000000000000000000..4d2844dbb9332d3fac2f634e7e996c375d105648 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15548.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2016 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15550.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15550.go new file mode 100644 index 0000000000000000000000000000000000000000..f2853fc48b5ce2d18e1acaa045d3c7beb41f06f0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15550.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2017 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 + +import "unsafe" + +const ( + _ = unsafe.Sizeof(func() int { + const ( + _ = 1 + _ + _ + ) + return 0 + }()) + + y = iota +) + +func main() { + if y != 1 { + panic(y) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15572.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15572.go new file mode 100644 index 0000000000000000000000000000000000000000..cf77778f6640fff699dd4474ea6772d672ce9685 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15572.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2016 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. + +// Test that exporting composite literals with implicit +// types doesn't crash the typechecker when running over +// inlined function bodies containing such literals. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15585.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15585.go new file mode 100644 index 0000000000000000000000000000000000000000..79eb13f90db45f4315f57433516a1bea82a73080 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15585.go @@ -0,0 +1,45 @@ +// compile + +// Copyright 2016 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 bug + +func example(n int) (rc int) { + var cc, ll, pp, rr [27]int + for q0 := 0; q0 < n-2; q0++ { + for q1 := q0 + 2; q1 < n; q1++ { + var c, d, l, p, r int + b0 := 1 << uint(q0) + b1 := 1 << uint(q1) + l = ((b0 << 1) | b1) << 1 + c = b0 | b1 | (-1 << uint(n)) + r = ((b0 >> 1) | b1) >> 1 + E: + if c != -1 { + p = ^(l | c | r) + } else { + rc++ + goto R + } + L: + if p != 0 { + lsb := p & -p + p &^= lsb + ll[d], cc[d], rr[d], pp[d] = l, c, r, p + l, c, r = (l|lsb)<<1, c|lsb, (r|lsb)>>1 + d++ + goto E + } + R: + d-- + if d >= 0 { + l, c, r, p = ll[d], cc[d], rr[d], pp[d] + goto L + } + } + } + rc <<= 1 + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15602.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15602.go new file mode 100644 index 0000000000000000000000000000000000000000..badf8133c5217623af4d0a179ad8f7bd72c09d4a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15602.go @@ -0,0 +1,11 @@ +// compile + +// Copyright 2016 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 p + +func f(i interface{}) { + i, _ = i.(error) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15604.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15604.go new file mode 100644 index 0000000000000000000000000000000000000000..4dc0b0b0541308650a6b03098ab329bf4d58e98f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15604.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 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 bug + +import "os" + +func f(err error) { + var ok bool + if err, ok = err.(*os.PathError); ok { + if err == os.ErrNotExist { + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15609.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15609.go new file mode 100644 index 0000000000000000000000000000000000000000..fa3b75501172013e2a82af016a4987c3ad61850a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15609.go @@ -0,0 +1,9 @@ +// runindir + +//go:build !nacl + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15611.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15611.go new file mode 100644 index 0000000000000000000000000000000000000000..3634475418d12eae67684f3fc80f9128c6e24a85 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15611.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 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 p + +// These error messages are for the invalid literals on lines 19 and 20: + +// ERROR "newline in character literal|newline in rune literal" +// ERROR "invalid character literal \(missing closing '\)|rune literal not terminated" + +const ( + _ = '' // ERROR "empty character literal or unescaped ' in character literal|empty rune literal" + _ = 'f' + _ = 'foo' // ERROR "invalid character literal \(more than one character\)|more than one character in rune literal" +//line issue15611.go:11 + _ = ' + _ = ' \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15646.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15646.go new file mode 100644 index 0000000000000000000000000000000000000000..cd4ba9d4e520350374a655e959856ef457736368 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15646.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2016 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. + +// Test that method expressions are correctly encoded +// in binary export data and can be imported again. +package ignore \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15722.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15722.go new file mode 100644 index 0000000000000000000000000000000000000000..dec54587f6b69b592e13f8fea638ea51e3ade9d4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15722.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2016 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. + +// Checks to make sure that the compiler can catch a specific invalid +// method type expression. NB: gccgo and gc have slightly different +// error messages, hence the generic test for 'method' and not something +// more specific. + +package issue15722 + +type T int +type P *T + +func (T) t() {} + +func _(p P) { + P.t(p) // ERROR "method" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15733.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15733.go new file mode 100644 index 0000000000000000000000000000000000000000..8f609e634dd8179d53afc3ead85195e025d1a10d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15733.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2016 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 + +type S struct { + a [1 << 16]byte +} + +func f1() { + p := &S{} + _ = p +} + +type T [1 << 16]byte + +func f2() { + p := &T{} + _ = p +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15747.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15747.go new file mode 100644 index 0000000000000000000000000000000000000000..92e762c4e923ac84b8ff2db61998ff0cdd7055df --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15747.go @@ -0,0 +1,44 @@ +// errorcheck -0 -live + +//go:build !goexperiment.cgocheck2 + +// Copyright 2016 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. + +// Issue 15747: liveness analysis was marking heap-escaped params live too much, +// and worse was using the wrong bitmap bits to do so. + +package p + +var global *[]byte + +type Q struct{} + +type T struct{ M string } + +var b bool + +func f1(q *Q, xx []byte) interface{} { // ERROR "live at call to newobject: xx$" "live at entry to f1: xx$" + // xx was copied from the stack to the heap on the previous line: + // xx was live for the first two prints but then it switched to &xx + // being live. We should not see plain xx again. + if b { + global = &xx + } + xx, _, err := f2(xx, 5) // ERROR "live at call to f2: &xx$" + if err != nil { + return err + } + return nil +} + +//go:noinline +func f2(d []byte, n int) (odata, res []byte, e interface{}) { // ERROR "live at entry to f2: d$" + if n > len(d) { + return d, nil, &T{M: "hello"} // ERROR "live at call to newobject: d" + } + res = d[:n] + odata = d[n:] + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15747b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15747b.go new file mode 100644 index 0000000000000000000000000000000000000000..bdb2a940c8f4bdfc131072131372841794e25465 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15747b.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2016 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. + +// Issue 15747: If an ODCL is dropped, for example when inlining, +// then it's easy to end up not initializing the '&x' pseudo-variable +// to point to an actual allocation. The liveness analysis will detect +// this and abort the computation, so this test just checks that the +// compilation succeeds. + +package p + +type R [100]byte + +func (x R) New() *R { + return &x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15838.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15838.go new file mode 100644 index 0000000000000000000000000000000000000000..fb1c64d1ac19dc6a6779cd2b7ad9d43856a01352 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15838.go @@ -0,0 +1,12 @@ +// compiledir + +// Copyright 2016 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. + +// Test cases for issue #15838, and related failures. +// Make sure the importer correctly sets up nodes for +// label decls, goto, continue, break, and fallthrough +// statements. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15895.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15895.go new file mode 100644 index 0000000000000000000000000000000000000000..3ef295c03ea5fde933dfe4a53521948c62b2500a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15895.go @@ -0,0 +1,27 @@ +// compile + +// Copyright 2016 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. + +// func bad used to fail to compile. + +package p + +type A [1]int + +func bad(x A) { + switch x { + case A([1]int{1}): + case A([1]int{1}): + } +} + +func good(x A) { + y := A([1]int{1}) + z := A([1]int{1}) + switch x { + case y: + case z: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15898.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15898.go new file mode 100644 index 0000000000000000000000000000000000000000..09f906ae582c19e929524ad968f27c768268fc42 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15898.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2016 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 p + +func f(e interface{}) { + switch e.(type) { + case nil, nil: // ERROR "multiple nil cases in type switch|duplicate type in switch|duplicate case nil in type switch" + } + + switch e.(type) { + case nil: + case nil: // ERROR "multiple nil cases in type switch|duplicate type in switch|duplicate case nil in type switch" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15902.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15902.go new file mode 100644 index 0000000000000000000000000000000000000000..9511a220edbd43c7ffb8b2e9c5c5b4ceaadd2935 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15902.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2016 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. + +// This test makes sure we don't use 4-byte unaligned writes +// to zero memory on architectures that don't support them. + +package main + +type T struct { + a byte + b [10]byte +} + +//go:noinline +func f(t *T) { + // t will be aligned, so &t.b won't be. + t.b = [10]byte{} +} + +var t T + +func main() { + f(&t) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15920.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15920.go new file mode 100644 index 0000000000000000000000000000000000000000..4d2844dbb9332d3fac2f634e7e996c375d105648 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15920.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2016 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15926.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15926.go new file mode 100644 index 0000000000000000000000000000000000000000..76e25eb640a478888f40ceabcb4a444e33b9ef25 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15926.go @@ -0,0 +1,20 @@ +// build + +// Copyright 2016 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. + +// Issue 15926: linker was adding .def to the end of symbols, causing +// a name collision with a method actually named def. + +package main + +type S struct{} + +func (s S) def() {} + +var I = S.def + +func main() { + I(S{}) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15961.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15961.go new file mode 100644 index 0000000000000000000000000000000000000000..db3d662378072e7c0b1cc8ad0b393c5148ae3300 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15961.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2016 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 y + +type symSet []int + +//go:noinline +func (s symSet) len() (r int) { + return 0 +} + +func f(m map[int]symSet) { + var symSet []int + for _, x := range symSet { + m[x] = nil + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15975.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15975.go new file mode 100644 index 0000000000000000000000000000000000000000..56a50e1176d4cc8b62571220b083be637c3dae1e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15975.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2016 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 + +var fail bool + +type Closer interface { + Close() +} + +func nilInterfaceDeferCall() { + var x Closer + defer x.Close() + // if it panics when evaluating x.Close, it should not reach here + fail = true +} + +func shouldPanic(f func()) { + defer func() { + if recover() == nil { + panic("did not panic") + } + }() + f() +} + +func main() { + shouldPanic(nilInterfaceDeferCall) + if fail { + panic("fail") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15988.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15988.go new file mode 100644 index 0000000000000000000000000000000000000000..2bed2a9c305e3fdc40ce4d7283ecd3a7c47966ad --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15988.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2016 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 p + +func f(p, q []int) { + p = append(q, 5) + sink = &p +} + +var sink *[]int diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15992.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue15992.go new file mode 100644 index 0000000000000000000000000000000000000000..cda5527c67edae1dfce778ea777fac26f8ec1efb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15992.go @@ -0,0 +1,38 @@ +// run + +// Copyright 2018 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 + +import ( + "fmt" +) + +func f(a []byte) ([]byte, []byte) { + return a, []byte("abc") +} + +func g(a []byte) ([]byte, string) { + return a, "abc" +} + +func h(m map[int]int) (map[int]int, int) { + return m, 0 +} + +func main() { + a := []byte{1, 2, 3} + n := copy(f(a)) + fmt.Println(n, a) + + b := []byte{1, 2, 3} + n = copy(g(b)) + fmt.Println(n, b) + + m := map[int]int{0: 0} + fmt.Println(len(m)) + delete(h(m)) + fmt.Println(len(m)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue15992.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue15992.out new file mode 100644 index 0000000000000000000000000000000000000000..e0011e3edb9917f4eb07e561aec18b4172fd73df --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue15992.out @@ -0,0 +1,4 @@ +3 [97 98 99] +3 [97 98 99] +1 +0 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16008.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16008.go new file mode 100644 index 0000000000000000000000000000000000000000..963137960bc3ff525fbdea1b2f20255cca97299b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16008.go @@ -0,0 +1,58 @@ +// errorcheck -0 -race + +//go:build (linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64) + +// Copyright 2016 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 foo + +const benchmarkNumNodes = 10000 + +func BenchmarkUpdateNodeTransaction(b B) { + s, nodeIDs := setupNodes(benchmarkNumNodes) + b.ResetTimer() + for i := 0; i < b.N(); i++ { + _ = s.Update(func(tx1 Tx) error { + _ = UpdateNode(tx1, &Node{ + ID: nodeIDs[i%benchmarkNumNodes], + }) + return nil + }) + } +} + +type B interface { + ResetTimer() + N() int +} + +type Tx interface { +} + +type Node struct { + ID string +} + +type MemoryStore struct { +} + +//go:noinline +func setupNodes(n int) (s *MemoryStore, nodeIDs []string) { + return +} + +//go:noinline +func (s *MemoryStore) Update(cb func(Tx) error) error { + return nil +} + +var sink interface{} + +//go:noinline +func UpdateNode(tx Tx, n *Node) error { + sink = tx + sink = n + return nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16016.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16016.go new file mode 100644 index 0000000000000000000000000000000000000000..e738e1dba0e99881486f27c10155c7c99d46a7bb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16016.go @@ -0,0 +1,35 @@ +// run + +// Copyright 2016 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 + +import "time" + +type T struct{} + +func (*T) Foo(vals []interface{}) { + switch v := vals[0].(type) { + case string: + _ = v + } +} + +type R struct{ *T } + +type Q interface { + Foo([]interface{}) +} + +func main() { + var q Q = &R{&T{}} + for i := 0; i < 10000; i++ { + go func() { + defer q.Foo([]interface{}{"meow"}) + time.Sleep(100 * time.Millisecond) + }() + } + time.Sleep(1 * time.Second) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16037_run.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16037_run.go new file mode 100644 index 0000000000000000000000000000000000000000..d5ad477391355283d4aae9343068ddc9196a13ac --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16037_run.go @@ -0,0 +1,71 @@ +// run + +//go:build !nacl && !js && !wasip1 && !android && !gccgo + +// Copyright 2016 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 + +import ( + "bytes" + "fmt" + "html/template" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" +) + +var tmpl = template.Must(template.New("main").Parse(` +package main + +type T struct { + {{range .Names}} + {{.Name}} *string + {{end}} +} + +{{range .Names}} +func (t *T) Get{{.Name}}() string { + if t.{{.Name}} == nil { + return "" + } + return *t.{{.Name}} +} +{{end}} + +func main() {} +`)) + +func main() { + const n = 5000 + + type Name struct{ Name string } + var t struct{ Names []Name } + for i := 0; i < n; i++ { + t.Names = append(t.Names, Name{Name: fmt.Sprintf("H%06X", i)}) + } + + buf := new(bytes.Buffer) + if err := tmpl.Execute(buf, t); err != nil { + log.Fatal(err) + } + + dir, err := ioutil.TempDir("", "issue16037-") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) + path := filepath.Join(dir, "ridiculous_number_of_fields.go") + if err := ioutil.WriteFile(path, buf.Bytes(), 0664); err != nil { + log.Fatal(err) + } + + out, err := exec.Command("go", "build", "-o="+filepath.Join(dir, "out"), path).CombinedOutput() + if err != nil { + log.Fatalf("build failed: %v\n%s", err, out) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16095.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16095.go new file mode 100644 index 0000000000000000000000000000000000000000..864b4b7c7cfcb29e182f2432c2edfa8d3d213b8a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16095.go @@ -0,0 +1,104 @@ +// run + +// Copyright 2016 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 + +import ( + "fmt" + "runtime" +) + +var sink *[20]byte + +func f() (x [20]byte) { + // Initialize x. + for i := range x { + x[i] = byte(i) + } + + // Force x to be allocated on the heap. + sink = &x + sink = nil + + // Go to deferreturn after the panic below. + defer func() { + recover() + }() + + // This call collects the heap-allocated version of x (oops!) + runtime.GC() + + // Allocate that same object again and clobber it. + y := new([20]byte) + for i := 0; i < 20; i++ { + y[i] = 99 + } + // Make sure y is heap allocated. + sink = y + + panic(nil) + + // After the recover we reach the deferreturn, which + // copies the heap version of x back to the stack. + // It gets the pointer to x from a stack slot that was + // not marked as live during the call to runtime.GC(). +} + +var sinkint int + +func g(p *int) (x [20]byte) { + // Initialize x. + for i := range x { + x[i] = byte(i) + } + + // Force x to be allocated on the heap. + sink = &x + sink = nil + + // Go to deferreturn after the panic below. + defer func() { + recover() + }() + + // This call collects the heap-allocated version of x (oops!) + runtime.GC() + + // Allocate that same object again and clobber it. + y := new([20]byte) + for i := 0; i < 20; i++ { + y[i] = 99 + } + // Make sure y is heap allocated. + sink = y + + // panic with a non-call (with no fallthrough) + for { + sinkint = *p + } + + // After the recover we reach the deferreturn, which + // copies the heap version of x back to the stack. + // It gets the pointer to x from a stack slot that was + // not marked as live during the call to runtime.GC(). +} + +func main() { + x := f() + for i, v := range x { + if v != byte(i) { + fmt.Printf("%v\n", x) + panic("bad f") + } + } + x = g(nil) + for i, v := range x { + if v != byte(i) { + fmt.Printf("%v\n", x) + panic("bad g") + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16130.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16130.go new file mode 100644 index 0000000000000000000000000000000000000000..c4e3ffd33db9fa15353b60eb65b0197574ed0391 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16130.go @@ -0,0 +1,43 @@ +// run + +// Copyright 2016 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. + +// Test that an interface conversion error panics with an "interface +// conversion" run-time error. It was (incorrectly) panicking with a +// "nil pointer dereference." + +package main + +import ( + "fmt" + "runtime" + "strings" +) + +type I interface { + Get() int +} + +func main() { + defer func() { + r := recover() + if r == nil { + panic("expected panic") + } + re, ok := r.(runtime.Error) + if !ok { + panic(fmt.Sprintf("got %T, expected runtime.Error", r)) + } + if !strings.Contains(re.Error(), "interface conversion") { + panic(fmt.Sprintf("got %q, expected interface conversion error", re.Error())) + } + }() + e := (interface{})(0) + if _, ok := e.(I); ok { + panic("unexpected interface conversion success") + } + fmt.Println(e.(I)) + panic("unexpected interface conversion success") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16133.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16133.go new file mode 100644 index 0000000000000000000000000000000000000000..4afffc5489bf8acca1843e60001b83511e2a6aa8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16133.go @@ -0,0 +1,10 @@ +// errorcheckdir -s + +// Copyright 2016 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. + +// Verify error messages referring to multiple different +// packages with the same package name. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16193.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16193.go new file mode 100644 index 0000000000000000000000000000000000000000..eada62de9ae33b0e802d95176ef1db12250d653a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16193.go @@ -0,0 +1,27 @@ +// compile + +// Copyright 2016 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. + +// The compiler used the name "glob" as the function holding a global +// function literal, colliding with an actual function named "glob". + +package main + +func glob() { + func() { + }() +} + +var c1 = func() { +} + +var c2 = func() { +} + +func main() { + glob() + c1() + c2() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16249.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16249.go new file mode 100644 index 0000000000000000000000000000000000000000..723d5d9fa6cf6bec6467e52adec049722d1d58bb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16249.go @@ -0,0 +1,58 @@ +// run + +// Copyright 2016 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. + +// Liveness calculations were wrong for a result parameter pushed onto +// the heap in a function that used defer. Program would crash with +// runtime: bad pointer in frame main.A at 0xc4201e6838: 0x1 + +package main + +import "errors" + +var sink interface{} + +//go:noinline +func f(err *error) { + if err != nil { + sink = err + } +} + +//go:noinline +func A(n, m int64) (res int64, err error) { + defer f(&err) // output parameter's address escapes to a defer. + if n < 0 { + err = errors.New("No negative") + return + } + if n <= 1 { + res = n + return + } + res = B(m) // This call to B drizzles a little junk on the stack. + res, err = A(n-1, m) + res++ + return +} + +// B does a little bit of recursion dribbling not-zero onto the stack. +//go:noinline +func B(n int64) (res int64) { + if n <= 1 { // Prefer to leave a 1 on the stack. + return n + } + return 1 + B(n-1) +} + +func main() { + x, e := A(0, 0) + for j := 0; j < 4; j++ { // j controls amount of B's stack dribble + for i := 0; i < 1000; i++ { // try more and more recursion until stack growth occurs in newobject in prologue + x, e = A(int64(i), int64(j)) + } + } + _, _ = x, e +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16306.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16306.go new file mode 100644 index 0000000000000000000000000000000000000000..d29a75a6044f7d6f3d080dd1933c9d43a6a97cc2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16306.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2016 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 + +import "unsafe" + +var x = unsafe.Pointer(uintptr(0)) + +func main() { + _ = map[unsafe.Pointer]int{unsafe.Pointer(uintptr(0)): 0} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16317.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16317.go new file mode 100644 index 0000000000000000000000000000000000000000..b3376bbbd7e27609d5899c59ca903bfef7ea2a44 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16317.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2016 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. + +// Issue 16317: cmd/compile: internal compiler error: +// unhandled OCONV INT -> TUNSAFEPTR + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16331.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16331.go new file mode 100644 index 0000000000000000000000000000000000000000..665e7fc0fd62e127a40e91cf1e9c54e1cbb94e41 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16331.go @@ -0,0 +1,48 @@ +// run + +// Copyright 2016 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. + +// Perform tracebackdefers with a deferred reflection method. + +package main + +import "reflect" + +type T struct{} + +func (T) M() { +} + +func F(args []reflect.Value) (results []reflect.Value) { + return nil +} + +func main() { + done := make(chan bool) + go func() { + // Test reflect.makeFuncStub. + t := reflect.TypeOf((func())(nil)) + f := reflect.MakeFunc(t, F).Interface().(func()) + defer f() + growstack(10000) + done <- true + }() + <-done + go func() { + // Test reflect.methodValueCall. + f := reflect.ValueOf(T{}).Method(0).Interface().(func()) + defer f() + growstack(10000) + done <- true + }() + <-done +} + +func growstack(x int) { + if x == 0 { + return + } + growstack(x - 1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16369.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16369.go new file mode 100644 index 0000000000000000000000000000000000000000..86d0ce645d2115c96eff74d96503cba6eca87c9f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16369.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2016 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 p + +type T interface { // ERROR "invalid recursive type: anonymous interface refers to itself" + M(interface { + T + }) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16428.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16428.go new file mode 100644 index 0000000000000000000000000000000000000000..91e1079959a0a3d79521b7fa23c784fd53cf5c98 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16428.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2016 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 p + +var ( + b = [...]byte("abc") // ERROR "outside of array literal|outside a composite literal" + s = len(b) +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16439.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16439.go new file mode 100644 index 0000000000000000000000000000000000000000..77baa1f4e8c9fdb8196d68eb8154413bba5b0f0e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16439.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2016 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 p + +var a []int = []int{1: 1} +var b []int = []int{-1: 1} // ERROR "must be non-negative integer constant|index expression is negative|must not be negative" + +var c []int = []int{2.0: 2} +var d []int = []int{-2.0: 2} // ERROR "must be non-negative integer constant|index expression is negative|must not be negative" + +var e []int = []int{3 + 0i: 3} +var f []int = []int{3i: 3} // ERROR "truncated to integer|index expression is not integer constant|truncated to int" + +var g []int = []int{"a": 4} // ERROR "must be non-negative integer constant|index expression is not integer constant|cannot convert" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16515.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16515.go new file mode 100644 index 0000000000000000000000000000000000000000..6b674363838328656103e240d6412b13aa8f97d3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16515.go @@ -0,0 +1,53 @@ +// run + +// Copyright 2016 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. + +// issue 16515: spilled Duff-adjusted address may be invalid + +package main + +import "runtime" + +type T [62]int // DUFFZERO with non-zero adjustment on AMD64 + +var sink interface{} + +//go:noinline +func zero(x *T) { + // Two DUFFZEROs on the same address with a function call in between. + // Duff-adjusted address will be spilled and loaded + + *x = T{} // DUFFZERO + runtime.GC() + (*x)[0] = 1 + g() // call a function with large frame, trigger a stack move + *x = T{} // DUFFZERO again +} + +//go:noinline +// a function with large frame +func g() { + var x [1000]int + _ = x +} + +func main() { + var s struct { a T; b [8192-62]int } // allocate 64K, hopefully it's in a new span and a few bytes before it is garbage + sink = &s // force heap allocation + s.a[0] = 2 + zero(&s.a) + if s.a[0] != 0 { + println("s.a[0] =", s.a[0]) + panic("zeroing failed") + } + + var a T // on stack + a[0] = 2 + zero(&a) + if a[0] != 0 { + println("a[0] =", a[0]) + panic("zeroing failed") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16616.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16616.go new file mode 100644 index 0000000000000000000000000000000000000000..a7d6ac095e54d72c80f2b841589f08c96fc75966 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16616.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2016 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. + +// Tests that unexported fields of unnamed types have different PkgPath values. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16733.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16733.go new file mode 100644 index 0000000000000000000000000000000000000000..850b042b621360254d6f52c71ae3b7fe06c9df42 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16733.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2016 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. + +// Issue 16733: don't fold constant factors into a multiply +// beyond the capacity of a MULQ instruction (32 bits). + +package p + +func f(n int64) int64 { + n *= 1000000 + n *= 1000000 + return n +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16741.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16741.go new file mode 100644 index 0000000000000000000000000000000000000000..9946062df77c8db8966ab3e3fda4362b5d1aec91 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16741.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 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. + +// Make sure CSE of multi-output opcodes works correctly +// with select0/1 operations. + +package main + +func div(d, r int64) int64 { + if m := d % r; m > 0 { + return d/r + 1 + } + return d / r +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16760.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16760.go new file mode 100644 index 0000000000000000000000000000000000000000..a7eede4d10b906303b7882a5f8d286a5d9588179 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16760.go @@ -0,0 +1,42 @@ +// run + +// Copyright 2016 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. + +// Make sure we don't start marshaling (writing to the stack) +// arguments until those arguments are evaluated and known +// not to unconditionally panic. If they unconditionally panic, +// we write some args but never do the call. That messes up +// the logic which decides how big the argout section needs to be. + +package main + +type W interface { + Write([]byte) +} + +type F func(W) + +func foo(f F) { + defer func() { + if r := recover(); r != nil { + usestack(1000) + } + }() + f(nil) +} + +func main() { + foo(func(w W) { + var x []string + w.Write([]byte(x[5])) + }) +} + +func usestack(n int) { + if n == 0 { + return + } + usestack(n - 1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16804.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16804.go new file mode 100644 index 0000000000000000000000000000000000000000..46dd4a33ccbf8109685dbf6925764f566f836681 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16804.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2016 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. + +// Issue 16804: internal error for math.Sqrt as statement +// rather than expression + +package main + +import "math" + +func sqrt() { + math.Sqrt(2.0) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16870.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16870.go new file mode 100644 index 0000000000000000000000000000000000000000..2309997cacf549056b08f36094c0cf000f07aee2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16870.go @@ -0,0 +1,140 @@ +// run + +// Copyright 2016 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 + +import ( + "log" + "reflect" +) + +func test(got, want interface{}) { + if !reflect.DeepEqual(got, want) { + log.Fatalf("got %v, want %v", got, want) + } +} + +func main() { + var i int + var ip *int + var ok interface{} + + // Channel receives. + c := make(chan int, 1) + c2 := make(chan int) + + c <- 42 + i, ok = <-c + test(i, 42) + test(ok, true) + + c <- 42 + _, ok = <-c + test(ok, true) + + c <- 42 + select { + case i, ok = <-c: + test(i, 42) + test(ok, true) + } + + c <- 42 + select { + case _, ok = <-c: + test(ok, true) + } + + c <- 42 + select { + case i, ok = <-c: + test(i, 42) + test(ok, true) + default: + log.Fatal("bad select") + } + + c <- 42 + select { + case _, ok = <-c: + test(ok, true) + default: + log.Fatal("bad select") + } + + c <- 42 + select { + case i, ok = <-c: + test(i, 42) + test(ok, true) + case <-c2: + log.Fatal("bad select") + } + + c <- 42 + select { + case _, ok = <-c: + test(ok, true) + case <-c2: + log.Fatal("bad select") + } + + close(c) + i, ok = <-c + test(i, 0) + test(ok, false) + + _, ok = <-c + test(ok, false) + + // Map indexing. + m := make(map[int]int) + + i, ok = m[0] + test(i, 0) + test(ok, false) + + _, ok = m[0] + test(ok, false) + + m[0] = 42 + i, ok = m[0] + test(i, 42) + test(ok, true) + + _, ok = m[0] + test(ok, true) + + // Type assertions. + var u interface{} + + i, ok = u.(int) + test(i, 0) + test(ok, false) + + ip, ok = u.(*int) + test(ip, (*int)(nil)) + test(ok, false) + + _, ok = u.(int) + test(ok, false) + + u = 42 + i, ok = u.(int) + test(i, 42) + test(ok, true) + + _, ok = u.(int) + test(ok, true) + + u = &i + ip, ok = u.(*int) + test(ip, &i) + test(ok, true) + + _, ok = u.(*int) + test(ok, true) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16948.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16948.go new file mode 100644 index 0000000000000000000000000000000000000000..c98602489614bd5a18ea83fcee76d6f48a4d1e08 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16948.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2016 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. + +// issue 16948: make sure intrinsified atomic ops won't +// confuse the scheduler. + +package main + +import "sync/atomic" + +func main() { + f() +} + +var x int32 + +type T [10]int +var sink *T + +func f() (t T) { + atomic.AddInt32(&x, 1) + g(42, 42, 42, 42, 42, &t) // use int values that is invalid pointer to smash the stack slot of return value of runtime.newobject + return +} + +//go:noinline +func g(a, b, c, d, e int, p *T) { + var t [10000]int // a large stack frame to trigger stack growing + _ = t + sink = p // force p (in caller) heap allocated +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16949.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16949.go new file mode 100644 index 0000000000000000000000000000000000000000..1007d701dec34a4944385dc1362e49b00e9b0630 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16949.go @@ -0,0 +1,30 @@ +// errorcheck + +// Copyright 2016 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. + +// Ensure that typed non-integer len and cap make arguments are not accepted. + +package main + +var sink []byte + +func main() { + sink = make([]byte, 1.0) + sink = make([]byte, float32(1.0)) // ERROR "non-integer.*len|must be integer" + sink = make([]byte, float64(1.0)) // ERROR "non-integer.*len|must be integer" + + sink = make([]byte, 0, 1.0) + sink = make([]byte, 0, float32(1.0)) // ERROR "non-integer.*cap|must be integer" + sink = make([]byte, 0, float64(1.0)) // ERROR "non-integer.*cap|must be integer" + + sink = make([]byte, 1+0i) + sink = make([]byte, complex64(1+0i)) // ERROR "non-integer.*len|must be integer" + sink = make([]byte, complex128(1+0i)) // ERROR "non-integer.*len|must be integer" + + sink = make([]byte, 0, 1+0i) + sink = make([]byte, 0, complex64(1+0i)) // ERROR "non-integer.*cap|must be integer" + sink = make([]byte, 0, complex128(1+0i)) // ERROR "non-integer.*cap|must be integer" + +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue16985.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue16985.go new file mode 100644 index 0000000000000000000000000000000000000000..0cb0dae51c435debf0ee4466e7356edc6e9e624b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue16985.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2016 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. + +// issue 16985: intrinsified AMD64 atomic ops should clobber flags + +package main + +import "sync/atomic" + +var count uint32 + +func main() { + buffer := []byte("T") + for i := 0; i < len(buffer); { + atomic.AddUint32(&count, 1) + _ = buffer[i] + i++ + i++ + } + + for i := 0; i < len(buffer); { + atomic.CompareAndSwapUint32(&count, 0, 1) + _ = buffer[i] + i++ + i++ + } + + for i := 0; i < len(buffer); { + atomic.SwapUint32(&count, 1) + _ = buffer[i] + i++ + i++ + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17005.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17005.go new file mode 100644 index 0000000000000000000000000000000000000000..e539519b6f56c63c62f0cbca47090a8f1348a2d8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17005.go @@ -0,0 +1,46 @@ +// compile + +// Copyright 2016 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. + +// This tickles (a version of) the PPC64 back end to +// emit a BVS instruction. + +package foo + +type Flag int + +const ( + Identity Flag = iota - 2 // H is the identity matrix; no rotation is needed. + Rescaling // H specifies rescaling. +) + +type DrotmParams struct { + Flag +} + +func Drotmg(d1, d2, x1, y1 float64) (p DrotmParams, rd1, rd2, rx1 float64) { + + const ( + gam = 4.0 + gamsq = 16.0 + rgamsq = 5e-8 + ) + + if d1 < 0 { + p.Flag = Rescaling + return + } + + for rd1 <= rgamsq || rd1 >= gamsq { + if rd1 <= rgamsq { + rd1 *= gam * gam + rx1 /= gam + } else { + rd1 /= gam * gam + rx1 *= gam + } + } + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17038.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17038.go new file mode 100644 index 0000000000000000000000000000000000000000..1b65ffc1f0eec68f2fdafe403bd64b4054368e15 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17038.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2016 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 A = complex(0()) // ERROR "cannot call non-function" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17039.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17039.go new file mode 100644 index 0000000000000000000000000000000000000000..1298e2bcc60c8f12091cbf7c796c1b4bba0e0483 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17039.go @@ -0,0 +1,17 @@ +// run + +// Copyright 2016 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 + +type S []S + +func main() { + var s S + s = append(s, s) // append a nil value to s + if s[0] != nil { + println("BUG: s[0] != nil") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17111.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17111.go new file mode 100644 index 0000000000000000000000000000000000000000..05284a785f50b9fa4aa7104361ec0d9e61e3632e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17111.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2016 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 + +type I int + +var ( + i int + x = I(i) + + e interface{} = x +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17194.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17194.go new file mode 100644 index 0000000000000000000000000000000000000000..0594e1cbdc13ae56f6de8697f6c81a8c6908bbbf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17194.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2016 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 foo + +func f(x []interface{}) (err error) { + for _, d := range x { + _, ok := d.(*int) + if ok { + return + } + } + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17270.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17270.go new file mode 100644 index 0000000000000000000000000000000000000000..5c009b58dfb7bb5543eb28c675f9afd6ae57a464 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17270.go @@ -0,0 +1,11 @@ +// compile + +// Copyright 2016 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 p + +import "unsafe" + +const _ = (unsafe.Sizeof)(0) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17318.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17318.go new file mode 100644 index 0000000000000000000000000000000000000000..21df729f092e5fbd9818eb662f8318ddece28dbe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17318.go @@ -0,0 +1,47 @@ +// errorcheck -0 -N -m -l + +// Copyright 2016 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. + +// The escape analyzer needs to run till its root set settles +// (this is not that often, it turns out). +// This test is likely to become stale because the leak depends +// on a spurious-escape bug -- return an interface as a named +// output parameter appears to cause the called closure to escape, +// where returning it as a regular type does not. + +package main + +import ( + "fmt" +) + +type closure func(i, j int) ent + +type ent int + +func (e ent) String() string { + return fmt.Sprintf("%d", int(e)) // ERROR "... argument does not escape$" "int\(e\) escapes to heap$" +} + +//go:noinline +func foo(ops closure, j int) (err fmt.Stringer) { // ERROR "ops does not escape" + enqueue := func(i int) fmt.Stringer { // ERROR "func literal does not escape" + return ops(i, j) // ERROR "ops\(i, j\) escapes to heap$" + } + err = enqueue(4) + if err != nil { + return err + } + return // return result of enqueue, a fmt.Stringer +} + +func main() { + // 3 identical functions, to get different escape behavior. + f := func(i, j int) ent { // ERROR "func literal does not escape" + return ent(i + j) + } + i := foo(f, 3).(ent) + fmt.Printf("foo(f,3)=%d\n", int(i)) // ERROR "int\(i\) escapes to heap$" "... argument does not escape$" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17328.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17328.go new file mode 100644 index 0000000000000000000000000000000000000000..ef60edbd426dd61ae7c08671954690d77bb078f9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17328.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2017 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 main() { + i := 0 + for ; ; i++) { // ERROR "unexpected \), expecting { after for clause|expected .*{.*|expected .*;.*" + } +} // GCCGO_ERROR "expected declaration" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17381.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17381.go new file mode 100644 index 0000000000000000000000000000000000000000..be63633e7fb5ec1d865697dba04b005ac4920f23 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17381.go @@ -0,0 +1,54 @@ +// run + +// Copyright 2016 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. + +// issue 17381: make sure leave function with non-empty frame +// saves link register, so that traceback will work. + +package main + +import ( + "runtime" + "unsafe" +) + +func main() { + defer func() { + if recover() == nil { + panic("did not panic") + } + pcs := make([]uintptr, 20) + n := runtime.Callers(1, pcs) + for _, pc := range pcs[:n] { + if runtime.FuncForPC(pc).Name() == "main.main" { + return + } + } + panic("cannot find main.main in backtrace") + }() + + prep() + f() // should panic +} + +func funcPC(f interface{}) uintptr { + var ptr uintptr + return **(**uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&f)) + unsafe.Sizeof(ptr))) +} + +//go:noinline +func f() { + var t [1]int // non-empty frame + *(*int)(nil) = t[0] +} + +var p = funcPC(runtime.GC) + 8 + +//go:noinline +func prep() { + // put some garbage on stack + var x = [20]uintptr{p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p, p} + _ = x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17449.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17449.go new file mode 100644 index 0000000000000000000000000000000000000000..4e092faa7ff86a88ffe6374b6d27d2f3f452dfea --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17449.go @@ -0,0 +1,36 @@ +// errorcheck -0 -race + +//go:build (linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64) + +// Copyright 2016 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. + +// Issue 17449: race instrumentation copies over previous instrumented nodes from parents block into child's Ninit block. +// This code surfaces the duplication at compile time because of generated inline labels. + +package master + +type PriorityList struct { + elems []interface{} +} + +func (x *PriorityList) Len() int { return len(x.elems) } + +func (l *PriorityList) remove(i int) interface{} { + elem := l.elems[i] + l.elems = append(l.elems[:i], l.elems[i+1:]...) + return elem +} + +func (l *PriorityList) Next() interface{} { + return l.remove(l.Len() - 1) +} + +var l *PriorityList + +func Foo() { + // It would fail here if instrumented code (including inline-label) was copied. + for elem := l.Next(); elem != nil; elem = l.Next() { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17551.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17551.go new file mode 100644 index 0000000000000000000000000000000000000000..b8751ab42dc87bbb706631a52546d36d7e87a7ed --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17551.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2016 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. + +// Issue 17551: inrange optimization failed to preserve type information. + +package main + +import "fmt" + +func main() { + _, x := X() + fmt.Printf("x = %v\n", x) +} + +func X() (i int, ok bool) { + ii := int(1) + return ii, 0 <= ii && ii <= 0x7fffffff +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17588.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17588.go new file mode 100644 index 0000000000000000000000000000000000000000..5c0787bf1db0594e3a762245141f4803f4ee612e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17588.go @@ -0,0 +1,20 @@ +// errorcheck -d=panic + +// Copyright 2016 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. + +// Issue 17588: internal compiler error in typecheckclosure() +// because in case of Func.Nname.Type == nil, Decldepth +// is not initialized in typecheckfunc(). This test +// produces that case. + +package p + +type F func(b T) // ERROR "T .*is not a type|expected type" + +func T(fn F) { + func() { + fn(nil) // If Decldepth is not initialized properly, typecheckclosure() Fatals here. + }() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17596.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17596.go new file mode 100644 index 0000000000000000000000000000000000000000..7398292d434d89817a6eb65f8d398c9f72635039 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17596.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2016 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 foo + +type T interface { + foo() +} + +func f() (T, int) + +func g(v interface{}) (interface{}, int) { + var x int + v, x = f() + return v, x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17631.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17631.go new file mode 100644 index 0000000000000000000000000000000000000000..742b054b34c36451f0758d8bcf31e7831f099bfe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17631.go @@ -0,0 +1,22 @@ +// errorcheck + +// Copyright 2016 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 + +import "time" + +func main() { + _ = struct { + about string + before map[string]uint + update map[string]int + updateTime time.Time + expect map[string]int + }{ + about: "this one", + updates: map[string]int{"gopher": 10}, // ERROR "unknown field updates in struct literal of type|unknown field .*updates.* in .*unnamed struct.*" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17640.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17640.go new file mode 100644 index 0000000000000000000000000000000000000000..a311521829a95f1a076b5e08f9011201a133fc0e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17640.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2016 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 + +import "fmt" + +var results string + +type TwoInts struct { + x, y int +} + +func f(x int) int { results = results + fmt.Sprintf("_%d", x); return x } + +func main() { + _ = [19]int{1: f(1), 0: f(0), 2: f(2), 6, 7} + _ = [2]int{1: f(4), 0: f(3)} + _ = TwoInts{y: f(6), x: f(5)} + _ = map[int]int{f(f(9) + 1): f(8), 0: f(7), f(22): -1} + if results != "_1_0_2_4_3_6_5_9_10_8_7_22" { + fmt.Printf("unexpected: %s\n", results) + panic("fail") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17645.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17645.go new file mode 100644 index 0000000000000000000000000000000000000000..6eed5f1a38a04e644fd6e41e2512399dc277bcfe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17645.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2016 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 + +type Foo struct { + X int +} + +func main() { + var s []int + var _ string = append(s, Foo{""}) // ERROR "cannot use append\(s, Foo{…}\) .* as string value in variable declaration" "cannot use Foo{…} .* as int value in argument to append" "cannot use .* as int value in struct literal" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17710.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17710.go new file mode 100644 index 0000000000000000000000000000000000000000..2843458c6118480168a5eb14cd6eef3112fb2043 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17710.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2016 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 + +import "runtime" + +func f(x interface{}) { + runtime.KeepAlive(x) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17752.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17752.go new file mode 100644 index 0000000000000000000000000000000000000000..83283ad6605ae7787ba04217658c1b6e5afe1770 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17752.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2016 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(m map[string]int) int { + return m["a"] +} + +func g(m map[[8]string]int) int { + return m[[8]string{"a", "a", "a", "a", "a", "a", "a", "a"}] +} + +func main() { + m := map[[8]string]int{} + g(m) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17758.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17758.go new file mode 100644 index 0000000000000000000000000000000000000000..8e40f9db7339a910e41970a97697336bec5b97fe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17758.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2020 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 foo() { + _ = func() {} +} + +func foo() { // ERROR "foo redeclared in this block|redefinition of .*foo.*" + _ = func() {} +} + +func main() {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue17918.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue17918.go new file mode 100644 index 0000000000000000000000000000000000000000..88ede6f7b71a5bbadad3f4a726edbac255e69357 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue17918.go @@ -0,0 +1,41 @@ +// compile + +// Copyright 2016 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. + +// Issue 17918: slice out-of-bounds in ssa/cse + +package dead + +import ( + "fmt" + "time" +) + +var ( + units = []struct { + divisor time.Duration + unit rune + }{ + {1000000, 's'}, + {60, 'm'}, + {60, 'h'}, + {24, 'd'}, + {7, 'w'}, + } +) + +func foobar(d time.Duration) string { + d /= time.Microsecond + unit := 'u' + + for _, f := range units { + if d%f.divisor != 0 { + break + } + d /= f.divisor + unit = f.unit + } + return fmt.Sprintf("%d%c", d, unit) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18089.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18089.go new file mode 100644 index 0000000000000000000000000000000000000000..fe5c1d48306d448d63c6ce7d06f4a7ed3425689d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18089.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2017 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 foo + +type T struct { + x int + _ int +} + +func main() { + _ = T{0, 0} + + x := T{1, 1} + _ = x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18092.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18092.go new file mode 100644 index 0000000000000000000000000000000000000000..c8e60f31c515fecbbb9c3120094c96843639302b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18092.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2016 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 p + +func _() { + var ch chan bool + select { + default: + case <-ch { // GCCGO_ERROR "expected colon" + } // GC_ERROR "expected :" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18149.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18149.go new file mode 100644 index 0000000000000000000000000000000000000000..112cd52530649f2ccfc8e8b5d1393adfda546c58 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18149.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2016 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. + +// Verify that //line directives with filenames +// containing ':' (Windows) are correctly parsed. +// (For a related issue, see test/fixedbugs/bug305.go) + +package main + +import ( + "fmt" + "runtime" +) + +func check(file string, line int) { + _, f, l, ok := runtime.Caller(1) + if !ok { + panic("runtime.Caller(1) failed") + } + if f != file || l != line { + panic(fmt.Sprintf("got %s:%d; want %s:%d", f, l, file, line)) + } +} + +func main() { +//line /foo/bar.go:123 + check(`/foo/bar.go`, 123) +//line c:/foo/bar.go:987 + check(`c:/foo/bar.go`, 987) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18231.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18231.go new file mode 100644 index 0000000000000000000000000000000000000000..774730405263eefa9f3182225e8ea038f44dcb10 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18231.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 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. + +// Test that error message for composite literals with +// missing type is at the right place. + +package p + +type T struct { + f map[string]string +} + +var _ = T{ + f: { // ERROR "missing type in composite literal|may only omit types within" + "a": "b", + }, +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18331.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18331.go new file mode 100644 index 0000000000000000000000000000000000000000..a527bcef63c38432123edeea4f4254e705d5608c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18331.go @@ -0,0 +1,20 @@ +// errorcheck -std +// Copyright 2017 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. +// Issue 18331: We should catch invalid pragma verbs +// for code that resides in the standard library. +package issue18331 + +//go:unknown // ERROR "//go:unknown is not allowed in the standard library" +func foo() + +//go:nowritebarrierc // ERROR "//go:nowritebarrierc is not allowed in the standard library" +func bar() + +//go:noesape // ERROR "//go:noesape is not allowed in the standard library" +func groot() + +//go:noescape +func hey() { // ERROR "can only use //go:noescape with external func implementations" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18392.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18392.go new file mode 100644 index 0000000000000000000000000000000000000000..32c39c3a7fea3a924e474138ca4436c9f8179d2e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18392.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2017 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 p + +type A interface { + // TODO(mdempsky): This should be an error, but this error is + // nonsense. The error should actually mention that there's a + // type loop. + Fn(A.Fn) // ERROR "type A has no method Fn|A.Fn undefined|A.Fn is not a type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18393.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18393.go new file mode 100644 index 0000000000000000000000000000000000000000..454392721f08ca69d39e52cb47a8c5667d94488c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18393.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2017 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. + +// Test that compiler directives are ignored if they +// don't start at the beginning of the line. + +package p + +//line issue18393.go:20 +import 42 // error on line 20 + + +/* //line not at start of line: ignored */ //line issue18393.go:30 +var x // error on line 24, not 30 + + +// ERROR "import path must be a string" + + + +// ERROR "syntax error: unexpected newline, expecting type|expected type" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18410.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18410.go new file mode 100644 index 0000000000000000000000000000000000000000..e9c6f862ebad51db0d7c9ffa698e623d2e77601c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18410.go @@ -0,0 +1,40 @@ +// run + +// Copyright 2016 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. + +// This checks partially initialized structure literals +// used to create value.method functions have their +// non-initialized fields properly zeroed/nil'd + +package main + +type X struct { + A, B, C *int +} + +//go:noinline +func (t X) Print() { + if t.B != nil { + panic("t.B must be nil") + } +} + +//go:noinline +func caller(f func()) { + f() +} + +//go:noinline +func test() { + var i, j int + x := X{A: &i, C: &j} + caller(func() { X{A: &i, C: &j}.Print() }) + caller(X{A: &i, C: &j}.Print) + caller(x.Print) +} + +func main() { + test() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18419.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18419.go new file mode 100644 index 0000000000000000000000000000000000000000..25544efd9b94c6dad01909ca293964b5fe029719 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18419.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2015 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18459.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18459.go new file mode 100644 index 0000000000000000000000000000000000000000..46601e70a4eb90e4e359b61c1d2fa2b919887d66 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18459.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2016 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. + +// Verify that we have a line number for this error. + +package main + +//go:nowritebarrier // ERROR "//go:nowritebarrier only allowed in runtime" +func main() { +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18595.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18595.go new file mode 100644 index 0000000000000000000000000000000000000000..d6f07b30e2ffdb6eee2b83f44b100d3016fe39be --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18595.go @@ -0,0 +1,53 @@ +// run + +// Copyright 2017 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. + +// This test makes sure that itabs are unique. +// More explicitly, we require that only one itab structure exists for the pair of +// a given compile-time interface type and underlying concrete type. +// Ensuring this invariant enables fixes for 18492 (improve type switch code). + +package main + +type I interface { + M() +} +type J interface { + M() +} + +type T struct{} + +func (*T) M() {} + +func main() { + test1() + test2() +} + +func test1() { + t := new(T) + var i1, i2 I + var j interface { + M() + } + i1 = t + j = t + i2 = j + if i1 != i2 { + panic("interfaces not equal") + } +} + +func test2() { + t := new(T) + i1 := (I)(t) + i2 := (I)((interface { + M() + })((J)(t))) + if i1 != i2 { + panic("interfaces not equal") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18636.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18636.go new file mode 100644 index 0000000000000000000000000000000000000000..2704fc46ee91fc7ffb940b540825f107d42d399a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18636.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2017 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 + +import "runtime/debug" + +type Foo struct { + A [1 << 20]byte + B string +} + +func run(c chan bool) { + f := new(Foo) + *f = Foo{B: "hello"} + c <- true +} + +func main() { + debug.SetMaxStack(1 << 16) + c := make(chan bool) + go run(c) + <-c +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18640.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18640.go new file mode 100644 index 0000000000000000000000000000000000000000..091bbe596b22baf09e1a2312cd1c93512885dd37 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18640.go @@ -0,0 +1,46 @@ +// compile + +// Copyright 2017 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 p + +type ( + a = b + b struct { + *a + } +) + +type ( + c struct { + *d + } + d = c +) + +// The compiler cannot handle these cases. Disabled for now. +// See issue #25838. +/* +type ( + e = f + f = g + g = []h + h i + i = j + j = e +) + +type ( + a1 struct{ *b1 } + b1 = c1 + c1 struct{ *b1 } +) + +type ( + a2 struct{ b2 } + b2 = c2 + c2 struct{ *b2 } +) +*/ diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18655.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18655.go new file mode 100644 index 0000000000000000000000000000000000000000..f34e5a9aeba05746ab60e09c70e6560229c5f24f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18655.go @@ -0,0 +1,22 @@ +// errorcheck + +// Copyright 2017 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 p + +type T struct{} +type A = T +type B = T + +func (T) m() {} +func (T) m() {} // ERROR "already declared|redefinition" +func (A) m() {} // ERROR "already declared|redefinition" +func (A) m() {} // ERROR "already declared|redefinition" +func (B) m() {} // ERROR "already declared|redefinition" +func (B) m() {} // ERROR "already declared|redefinition" + +func (*T) m() {} // ERROR "already declared|redefinition" +func (*A) m() {} // ERROR "already declared|redefinition" +func (*B) m() {} // ERROR "already declared|redefinition" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18661.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18661.go new file mode 100644 index 0000000000000000000000000000000000000000..e64a771a83dcd0b26ff6eb82500afe6a4a5bf45a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18661.go @@ -0,0 +1,39 @@ +// run + +// Copyright 2017 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 + +import ( + "fmt" + "os" +) + +var ( + e interface{} + s = struct{ a *int }{} + b = e == s +) + +func test(obj interface{}) { + if obj != struct{ a *string }{} { + } +} + +var x int + +func f() [2]string { + x++ + return [2]string{"abc", "def"} +} + +func main() { + var e interface{} = [2]string{"abc", "def"} + _ = e == f() + if x != 1 { + fmt.Println("x=", x) + os.Exit(1) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18725.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18725.go new file mode 100644 index 0000000000000000000000000000000000000000..c632dbad639e4b9c72372d7f5cba749059641cb3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18725.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2017 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 + +import "os" + +func panicWhenNot(cond bool) { + if cond { + os.Exit(0) + } else { + panic("nilcheck elim failed") + } +} + +func main() { + e := (*string)(nil) + panicWhenNot(e == e) + // Should never reach this line. + panicWhenNot(*e == *e) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18747.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18747.go new file mode 100644 index 0000000000000000000000000000000000000000..4eabe0e61df5983ef6670f2bd33263fbe00ef567 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18747.go @@ -0,0 +1,28 @@ +// errorcheck + +// Copyright 2017 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 p + +func _ () { + if {} // ERROR "missing condition in if statement" + + if + {} // ERROR "missing condition in if statement" + + if ; {} // ERROR "missing condition in if statement" + + if foo; {} // ERROR "missing condition in if statement" + + if foo; // ERROR "missing condition in if statement" + {} + + if foo {} + + if ; foo {} + + if foo // ERROR "unexpected newline, expected { after if clause" + {} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18808.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18808.go new file mode 100644 index 0000000000000000000000000000000000000000..c98386ee7847e6e7e68c659acd6dc40902a4c40b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18808.go @@ -0,0 +1,63 @@ +// run + +// Copyright 2017 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 lim = 0x80000000 + +//go:noinline +func eq(x uint32) { + if x == lim { + return + } + panic("x == lim returned false") +} + +//go:noinline +func neq(x uint32) { + if x != lim { + panic("x != lim returned true") + } +} + +//go:noinline +func gt(x uint32) { + if x > lim { + return + } + panic("x > lim returned false") +} + +//go:noinline +func gte(x uint32) { + if x >= lim { + return + } + panic("x >= lim returned false") +} + +//go:noinline +func lt(x uint32) { + if x < lim { + panic("x < lim returned true") + } +} + +//go:noinline +func lte(x uint32) { + if x <= lim { + panic("x <= lim returned true") + } +} + +func main() { + eq(lim) + neq(lim) + gt(lim+1) + gte(lim+1) + lt(lim+1) + lte(lim+1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18882.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18882.go new file mode 100644 index 0000000000000000000000000000000000000000..9c3658d67c8237fc534d133b7ace0101fa3fb8c9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18882.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2017 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. + +// Verify that we have a line number for this error. + +package main + +//go:cgo_ldflag // ERROR "usage: //go:cgo_ldflag" +func main() { +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18895.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18895.go new file mode 100644 index 0000000000000000000000000000000000000000..61cff6e1b050faf73f7b972698901d4b81d08474 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18895.go @@ -0,0 +1,7 @@ +// errorcheckdir -0 -m + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18906.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18906.go new file mode 100644 index 0000000000000000000000000000000000000000..544400be25845f0cc18523d404a511d3944b364d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18906.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2017 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 + +//go:noinline +func f(x int) { +} + +//go:noinline +func val() int8 { + return -1 +} + +var ( + array = [257]int{} + slice = array[1:] +) + +func init() { + for i := range array { + array[i] = i - 1 + } +} + +func main() { + x := val() + y := int(uint8(x)) + f(y) // try and force y to be calculated and spilled + if slice[y] != 255 { + panic("incorrect value") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18911.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18911.go new file mode 100644 index 0000000000000000000000000000000000000000..8bf34a382afc3687a03a1098368abcaff70d3e4b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18911.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2018 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 ignore diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18915.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18915.go new file mode 100644 index 0000000000000000000000000000000000000000..cf248b1f0becf7b3fd95f002322a774a38c7151b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18915.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2017 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. + +// Make sure error message for invalid conditions +// or tags are consistent with earlier Go versions. + +package p + +func _() { + if a := 10 { // ERROR "cannot use a := 10 as value|expected .*;|declared and not used" + } + + for b := 10 { // ERROR "cannot use b := 10 as value|parse error|declared and not used" + } + + switch c := 10 { // ERROR "cannot use c := 10 as value|expected .*;|declared and not used" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue18994.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue18994.go new file mode 100644 index 0000000000000000000000000000000000000000..aa307139f53ffebb95df4fbaf57aec567875e00c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue18994.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2017 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. + +// Issue 18994: SSA didn't handle DOT STRUCTLIT for zero-valued +// STRUCTLIT. + +package main + +// large struct - not SSA-able +type T struct { + a, b, c, d, e, f, g, h int +} + +func main() { + x := T{}.a + if x != 0 { + panic("FAIL") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19012.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19012.go new file mode 100644 index 0000000000000000000000000000000000000000..77b22360635eea769edd5132a2b35d0312e5022e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19012.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 19012: if we have any unknown type at a call site, +// we must ensure that we return to the user a suppressed +// error message saying instead of including in +// the message. + +package main + +func f(x int, y uint) { + if true { + return "a" > 10 // ERROR "^too many arguments to return$|return with value in function with no return|no result values expected|mismatched types" + } + return "gopher" == true, 10 // ERROR "^too many arguments to return$|return with value in function with no return|no result values expected|mismatched types" +} + +func main() { + f(2, 3 < "x", 10) // ERROR "too many arguments|invalid operation|incompatible type" + + f(10, 10, "a") // ERROR "too many arguments" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19028.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19028.go new file mode 100644 index 0000000000000000000000000000000000000000..8d934d2d6716e6c0da30dc07bbb1088ead02ff66 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19028.go @@ -0,0 +1,13 @@ +// rundir + +// Copyright 2017 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. + +// This test failed when the compiler didn't use the +// correct code to identify the type reflect.Method. +// The failing code relied on Type.String() which had +// formatting that depended on whether a package (in +// this case "reflect") was imported more than once. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19040.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19040.go new file mode 100644 index 0000000000000000000000000000000000000000..67881df6243131bf5f3095339cef1d28d0bcdc85 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19040.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2017 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. + +// Check the text of the panic that comes from +// a nil pointer passed to automatically generated method wrapper. + +package main + +import "fmt" + +type T int + +type I interface { + F() +} + +func (t T) F() {} + +var ( + t *T + i I = t +) + +func main() { + defer func() { + got := recover().(error).Error() + want := "value method main.T.F called using nil *T pointer" + if got != want { + fmt.Printf("panicwrap error text:\n\t%q\nwant:\n\t%q\n", got, want) + } + }() + i.F() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19056.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19056.go new file mode 100644 index 0000000000000000000000000000000000000000..d279eaa3cf64bf0a77f740d4551320e31b694e3f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19056.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2017 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 p + +var _ = ... . // ERROR "unexpected ...|expected operand|expected .*;" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19078.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19078.go new file mode 100644 index 0000000000000000000000000000000000000000..b19e8749d7a2d05da76194b240732a816770d6ee --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19078.go @@ -0,0 +1,42 @@ +// run + +// Copyright 2017 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. + +// Issue 19078: liveness & zero-initialization of results +// when there is a defer. +package main + +import "unsafe" + +func main() { + // Construct an invalid pointer. We do this by + // making a pointer which points to the unused space + // between the last 48-byte object in a span and the + // end of the span (there are 32 unused bytes there). + p := new([48]byte) // make a 48-byte object + sink = &p // escape it, so it allocates for real + u := uintptr(unsafe.Pointer(p)) // get its address + u = u >> 13 << 13 // round down to page size + u += 1<<13 - 1 // add almost a page + + for i := 0; i < 1000000; i++ { + _ = identity(u) // installs u at return slot + _ = liveReturnSlot(nil) // incorrectly marks return slot as live + } +} + +//go:noinline +func liveReturnSlot(x *int) *int { + defer func() {}() // causes return slot to be marked live + sink = &x // causes x to be moved to the heap, triggering allocation + return x +} + +//go:noinline +func identity(x uintptr) uintptr { + return x +} + +var sink interface{} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19084.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19084.go new file mode 100644 index 0000000000000000000000000000000000000000..ba5306320b5a39731748d13e72de951678c0bcf5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19084.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2017 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. + +// Issue 19084: SSA doesn't handle CONVNOP STRUCTLIT + +package p + +type T struct { + a, b, c, d, e, f, g, h int // big, not SSA-able +} + +func f() { + _ = T(T{}) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19113.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19113.go new file mode 100644 index 0000000000000000000000000000000000000000..5e01dde699c3c68aa217e8772534d5914c7efb09 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19113.go @@ -0,0 +1,108 @@ +// run + +// Copyright 2019 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 + +import "reflect" + +var tests = []interface{}{ + func(x int, s int) int { + return x << s + }, + func(x int, s int64) int { + return x << s + }, + func(x int, s int32) int { + return x << s + }, + func(x int, s int16) int { + return x << s + }, + func(x int, s int8) int { + return x << s + }, + func(x int, s int) int { + return x >> s + }, + func(x int, s int64) int { + return x >> s + }, + func(x int, s int32) int { + return x >> s + }, + func(x int, s int16) int { + return x >> s + }, + func(x int, s int8) int { + return x >> s + }, + func(x uint, s int) uint { + return x << s + }, + func(x uint, s int64) uint { + return x << s + }, + func(x uint, s int32) uint { + return x << s + }, + func(x uint, s int16) uint { + return x << s + }, + func(x uint, s int8) uint { + return x << s + }, + func(x uint, s int) uint { + return x >> s + }, + func(x uint, s int64) uint { + return x >> s + }, + func(x uint, s int32) uint { + return x >> s + }, + func(x uint, s int16) uint { + return x >> s + }, + func(x uint, s int8) uint { + return x >> s + }, +} + +func main() { + for _, t := range tests { + runTest(reflect.ValueOf(t)) + } +} + +func runTest(f reflect.Value) { + xt := f.Type().In(0) + st := f.Type().In(1) + + for _, x := range []int{1, 0, -1} { + for _, s := range []int{-99, -64, -63, -32, -31, -16, -15, -8, -7, -1, 0, 1, 7, 8, 15, 16, 31, 32, 63, 64, 99} { + args := []reflect.Value{ + reflect.ValueOf(x).Convert(xt), + reflect.ValueOf(s).Convert(st), + } + if s < 0 { + shouldPanic(func() { + f.Call(args) + }) + } else { + f.Call(args) // should not panic + } + } + } +} + +func shouldPanic(f func()) { + defer func() { + if recover() == nil { + panic("did not panic") + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19137.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19137.go new file mode 100644 index 0000000000000000000000000000000000000000..0539a850ca69cba4c45ab469abc9cdedd8c5c002 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19137.go @@ -0,0 +1,51 @@ +// compile + +// Copyright 2017 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. + +// Issue 19137: folding address into load/store causes +// odd offset on ARM64. + +package p + +type T struct { + p *int + a [2]byte + b [6]byte // not 4-byte aligned +} + +func f(b [6]byte) T { + var x [1000]int // a large stack frame + _ = x + return T{b: b} +} + +// Arg symbol's base address may be not at an aligned offset to +// SP. Folding arg's address into load/store may cause odd offset. +func move(a, b [20]byte) [20]byte { + var x [1000]int // a large stack frame + _ = x + return b // b is not 8-byte aligned to SP +} +func zero() ([20]byte, [20]byte) { + var x [1000]int // a large stack frame + _ = x + return [20]byte{}, [20]byte{} // the second return value is not 8-byte aligned to SP +} + +// Issue 21992: unaligned offset between 256 and 504 and handled +// incorrectly. +type T2 struct { + a [257]byte + // fields below are not 8-, 4-, 2-byte aligned + b [8]byte + c [4]byte + d [2]byte +} + +func f2(x *T2) { + x.b = [8]byte{} + x.c = [4]byte{} + x.d = [2]byte{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19168.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19168.go new file mode 100644 index 0000000000000000000000000000000000000000..b94b1d0a993d849f20fbfd6770291b8cd57457dc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19168.go @@ -0,0 +1,58 @@ +// errorcheck -0 -l -d=wb + +// Copyright 2017 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 p + +import ( + "reflect" + "unsafe" + + reflect2 "reflect" +) + +func sink(e interface{}) + +func a(hdr *reflect.SliceHeader, p *byte) { + hdr.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" +} + +func b(hdr *reflect.StringHeader, p *byte) { + hdr.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" +} + +func c(hdrs *[1]reflect.SliceHeader, p *byte) { + hdrs[0].Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" +} + +func d(hdr *struct{ s reflect.StringHeader }, p *byte) { + hdr.s.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" +} + +func e(p *byte) (resHeap, resStack string) { + sink(&resHeap) + + hdr := (*reflect.StringHeader)(unsafe.Pointer(&resHeap)) + hdr.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" + + // No write barrier for non-escaping stack vars. + hdr = (*reflect.StringHeader)(unsafe.Pointer(&resStack)) + hdr.Data = uintptr(unsafe.Pointer(p)) + + return +} + +func f(hdr *reflect2.SliceHeader, p *byte) { + hdr.Data = uintptr(unsafe.Pointer(p)) // ERROR "write barrier" +} + +type SliceHeader struct { + Data uintptr +} + +func g(hdr *SliceHeader, p *byte) { + // No write barrier for lookalike SliceHeader. + hdr.Data = uintptr(unsafe.Pointer(p)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19182.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19182.go new file mode 100644 index 0000000000000000000000000000000000000000..544c4b0cebce7c19d706d67d91504dbb620bfcb6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19182.go @@ -0,0 +1,38 @@ +// run + +//go:build !js && !wasip1 + +// Copyright 2017 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 + +import ( + "fmt" + "runtime" + "sync/atomic" + "time" +) + +var a uint64 = 0 + +func main() { + runtime.GOMAXPROCS(2) // With just 1, infinite loop never yields + + go func() { + for { + atomic.AddUint64(&a, uint64(1)) + } + }() + + time.Sleep(10 * time.Millisecond) // Short sleep is enough in passing case + i, val := 0, atomic.LoadUint64(&a) + for ; val == 0 && i < 100; val, i = atomic.LoadUint64(&a), i+1 { + time.Sleep(100 * time.Millisecond) + } + if val == 0 { + fmt.Printf("Failed to observe atomic increment after %d tries\n", i) + } + +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19201.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19201.go new file mode 100644 index 0000000000000000000000000000000000000000..e370d55df15d296805c2ff566f65d7caab1f16dc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19201.go @@ -0,0 +1,52 @@ +// run + +// Copyright 2017 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 + +import ( + "encoding/binary" +) + +var ( + ch1 = make(chan int) + ch2 = make(chan int) + + bin = []byte("a\000\000\001") + want = binary.BigEndian.Uint32(bin) + + c consumer = noopConsumer{} +) + +type msg struct { + code uint32 +} + +type consumer interface { + consume(msg) +} + +type noopConsumer struct{} + +func (noopConsumer) consume(msg) {} + +func init() { + close(ch1) +} + +func main() { + var m msg + m.code = binary.BigEndian.Uint32(bin) + + select { + case <-ch1: + c.consume(m) + if m.code != want { + // can not use m.code here, or it will work + panic("BigEndian read failed") + } + case <-ch2: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19217.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19217.go new file mode 100644 index 0000000000000000000000000000000000000000..96794064a40caef274f348ccfbb899dfabab2a24 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19217.go @@ -0,0 +1,39 @@ +// compile + +// Copyright 2017 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 foo + +import ( + "encoding/binary" +) + +type DbBuilder struct { + arr []int +} + +func (bld *DbBuilder) Finish() error { + defer bld.Finish() + + var hash []byte + for _, ixw := range bld.arr { + for { + if ixw != 0 { + panic("ixw != 0") + } + ixw-- + insertOne: + for { + for i := 0; i < 1; i++ { + if binary.LittleEndian.Uint16(hash[i:]) == 0 { + break insertOne + } + } + } + } + } + + return nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19246.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19246.go new file mode 100644 index 0000000000000000000000000000000000000000..3ece2a1cbe4666d64ffa272df6fd816a2783f1a4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19246.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2017 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. + +// Issue 19246: Failed to evaluate some zero-sized values +// when converting them to interfaces. + +package main + +import "os" + +type B struct{} + +//go:noinline +func f(i interface{}) {} + +func main() { + defer func() { + if recover() == nil { + println("expected nil pointer dereference panic") + os.Exit(1) + } + }() + var b *B + f(*b) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19261.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19261.go new file mode 100644 index 0000000000000000000000000000000000000000..1da90e94caf60461c8d083e1c5ad53098bb2d40c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19261.go @@ -0,0 +1,9 @@ +// errorcheckdir -0 -m + +//go:build !goexperiment.newinliner + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19275.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19275.go new file mode 100644 index 0000000000000000000000000000000000000000..f7e64fc9aece974df451502f3bc4f9c3a71e1624 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19275.go @@ -0,0 +1,72 @@ +// run + +// Copyright 2017 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 + +import ( + "fmt" +) + +type PI struct { + Enabled bool +} + +type SI struct { + M map[string]*PI +} + +//go:noinline +func (s *SI) test(name string) (*int, error) { + n := new(int) + *n = 99 + if err := addUpdate(n, s.M[name].Enabled, "enabled"); err != nil { // this was miscompiled + return nil, fmt.Errorf(" error adding update for enable flag %t : %s", + s.M[name].Enabled, err) + } + return n, nil +} + +//go:noinline +func addUpdate(n *int, in interface{}, s ...string) error { + if *n != 99 { + println("FAIL, *n should be 99, not", *n) + } + return nil +} + +func main1() { + s := &SI{make(map[string]*PI)} + s.M["dog"] = &PI{} + s.test("dog") +} + +//go:noinline +func g(b *byte, i interface{}) error { + if *b != 17 { + println("FAIL, *b should be 17, not", *b) + } + return nil +} + +//go:noinline +func f(x *byte, m map[string]*bool) { + if err := g(x, *m["hello"]); err != nil { // this was miscompiled + return + } +} + +func main2() { + m := make(map[string]*bool) + x := false + m["hello"] = &x + b := byte(17) + f(&b, m) +} + +func main() { + main2() + main1() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19323.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19323.go new file mode 100644 index 0000000000000000000000000000000000000000..5db0a48a345faf5a25247ed1ac46b2fd4f8a50b6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19323.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2017 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 p + +func g() {} + +func f() { + g()[:] // ERROR "g.* used as value|attempt to slice object that is not" +} + +func g2() ([]byte, []byte) { return nil, nil } + +func f2() { + g2()[:] // ERROR "multiple-value g2.* in single-value context|attempt to slice object that is not|2\-valued g" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19359.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19359.go new file mode 100644 index 0000000000000000000000000000000000000000..cc3ecc84f61741354db14a90816ce481e0e9f521 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19359.go @@ -0,0 +1,91 @@ +// run + +// Copyright 2017 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 + +import "fmt" + +func set(m map[interface{}]interface{}, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("set failed: %v", r) + } + }() + m[key] = nil + return nil +} + +func del(m map[interface{}]interface{}, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("del failed: %v", r) + } + }() + delete(m, key) + return nil +} + +func addInt(m map[interface{}]int, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("addInt failed: %v", r) + } + }() + m[key] += 2018 + return nil +} + +func addStr(m map[interface{}]string, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("addStr failed: %v", r) + } + }() + m[key] += "hello, go" + return nil +} + +func appendInt(m map[interface{}][]int, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("appendInt failed: %v", r) + } + }() + m[key] = append(m[key], 2018) + return nil +} + +func appendStr(m map[interface{}][]string, key interface{}) (err error) { + defer func() { + if r := recover(); r != nil { + err = fmt.Errorf("addStr failed: %v", r) + } + }() + m[key] = append(m[key], "hello, go") + return nil +} + +func main() { + m := make(map[interface{}]interface{}) + set(m, []int{1, 2, 3}) + set(m, "abc") // used to throw + del(m, []int{1, 2, 3}) + del(m, "abc") // used to throw + + mi := make(map[interface{}]int) + addInt(mi, []int{1, 2, 3}) + addInt(mi, "abc") // used to throw + + ms := make(map[interface{}]string) + addStr(ms, []int{1, 2, 3}) + addStr(ms, "abc") // used to throw + + mia := make(map[interface{}][]int) + appendInt(mia, []int{1, 2, 3}) + + msa := make(map[interface{}][]string) + appendStr(msa, "abc") // used to throw +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19467.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19467.go new file mode 100644 index 0000000000000000000000000000000000000000..42121575ec3c61b3714138d50243284199b24d9b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19467.go @@ -0,0 +1,7 @@ +// rundir -l=4 + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19482.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19482.go new file mode 100644 index 0000000000000000000000000000000000000000..b67dda5a1f8ba433dd119e9cd002b05ec0062e67 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19482.go @@ -0,0 +1,34 @@ +// errorcheck + +// Copyright 2017 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. + +// Compiler rejected initialization of structs to composite literals +// in a non-static setting (e.g. in a function) +// when the struct contained a field named _. + +package p + +type T struct { + _ string +} + +func ok() { + var x = T{"check"} + _ = x + _ = T{"et"} +} + +var ( + y = T{"stare"} + w = T{_: "look"} // ERROR "invalid field name _ in struct initializer|expected struct field name|unknown field _ in struct literal of type T" + _ = T{"page"} + _ = T{_: "out"} // ERROR "invalid field name _ in struct initializer|expected struct field name|unknown field _ in struct literal of type T" +) + +func bad() { + var z = T{_: "verse"} // ERROR "invalid field name _ in struct initializer|expected struct field name|unknown field _ in struct literal of type T" + _ = z + _ = T{_: "itinerary"} // ERROR "invalid field name _ in struct initializer|expected struct field name|unknown field _ in struct literal of type T" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19507.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19507.go new file mode 100644 index 0000000000000000000000000000000000000000..ef0a9a1b78218b1e3c0be396e3af74f857f964b4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19507.go @@ -0,0 +1,9 @@ +// builddir + +//go:build arm + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19515.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19515.go new file mode 100644 index 0000000000000000000000000000000000000000..a1605bec9633577281dfb17fc2d2b14e162150e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19515.go @@ -0,0 +1,51 @@ +// compile + +// Copyright 2017 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. + +// Issue 19515: compiler panics on spilling int128 constant. + +package x + +type VScrollPanel struct { + x, y int +} + +type Color struct { + R, G, B, A float32 +} + +func maxF(a, b float32) float32 { + if a > b { + return 0 + } + return 1 +} + +type TransformMatrix [6]float32 + +type Paint struct { + xform TransformMatrix + feather float32 + innerColor Color + outerColor Color +} + +func BoxGradient(x, y, w, h, f float32, iColor, oColor Color) Paint { + return Paint{ + xform: TransformMatrix{9, 0, 0, 0, x, y}, + feather: maxF(1.0, f), + innerColor: iColor, + outerColor: oColor, + } +} + +func (v *VScrollPanel) Draw() { + x := float32(v.x) + y := float32(v.y) + + BoxGradient(x+x-2, y-1, 0, 0, 0, Color{}, Color{}) + BoxGradient(x+y-2, y-1, 0, 0, 0, Color{}, Color{}) +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19548.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19548.go new file mode 100644 index 0000000000000000000000000000000000000000..e0e769338a5427eb6bb8e4de772ceb5c41e5c0bd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19548.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2017 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. + +// Test that interface wrappers can be compiled successfully +// in multiple translation units. +package ignore diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19555.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19555.go new file mode 100644 index 0000000000000000000000000000000000000000..53b2ebde51e1ca7d49b5d65581664e74ac4330d6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19555.go @@ -0,0 +1,36 @@ +// compile + +// Copyright 2017 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 p + +type NodeLink struct{} + +// A role our end of NodeLink is intended to play +type LinkRole int64 + +const ( + LinkServer LinkRole = iota // link created as server + LinkClient // link created as client + + // for testing: + linkNoRecvSend LinkRole = 1 << 16 // do not spawn serveRecv & serveSend + linkFlagsMask LinkRole = (1<<32 - 1) << 16 +) + +func NewNodeLink(role LinkRole) *NodeLink { + var nextConnId uint32 + switch role &^ linkFlagsMask { + case LinkServer: + nextConnId = 0 // all initiated by us connId will be even + case LinkClient: + nextConnId = 1 // ----//---- odd + default: + panic("invalid conn role") + } + + _ = nextConnId + return nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19610.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19610.go new file mode 100644 index 0000000000000000000000000000000000000000..01beda3998a269bf34d1f3455645afca323459b0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19610.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2017 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 main() { + for ; ; x := 1 { // ERROR "cannot declare in post statement" + _ = x + break + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19632.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19632.go new file mode 100644 index 0000000000000000000000000000000000000000..41cb1ffa1de2788d2fce2c5445804a5b41f4e00e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19632.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2017 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. + +// Check that we don't crash due to "lost track of variable in +// liveness" errors against unused variables. + +package p + +import "strings" + +// Minimized test case from github.com/mvdan/sh/syntax. +func F() { + var _ = []string{ + strings.Repeat("\n\n\t\t \n", 10) + + "# " + strings.Repeat("foo bar ", 10) + "\n" + + strings.Repeat("longlit_", 10) + "\n", + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19658.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19658.go new file mode 100644 index 0000000000000000000000000000000000000000..1e13573b72bc971d75e4a524674035cbf493149f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19658.go @@ -0,0 +1,100 @@ +// run +//go:build !nacl && !js && !wasip1 && !gccgo + +// Copyright 2017 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. + +// ensure that panic(x) where x is a numeric type displays a readable number +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" +) + +const fn = ` +package main + +import "errors" +type S struct { + +} +func (s S) String() string { + return "s-stringer" +} +func main() { + _ = errors.New + panic(%s(%s)) +} +` + +func main() { + tempDir, err := ioutil.TempDir("", "") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(tempDir) + tmpFile := filepath.Join(tempDir, "tmp.go") + + for _, tc := range []struct { + Type string + Input string + Expect string + }{ + {"", "nil", "panic: panic called with nil argument"}, + {"errors.New", `"test"`, "panic: test"}, + {"S", "S{}", "panic: s-stringer"}, + {"byte", "8", "panic: 8"}, + {"rune", "8", "panic: 8"}, + {"int", "8", "panic: 8"}, + {"int8", "8", "panic: 8"}, + {"int16", "8", "panic: 8"}, + {"int32", "8", "panic: 8"}, + {"int64", "8", "panic: 8"}, + {"uint", "8", "panic: 8"}, + {"uint8", "8", "panic: 8"}, + {"uint16", "8", "panic: 8"}, + {"uint32", "8", "panic: 8"}, + {"uint64", "8", "panic: 8"}, + {"uintptr", "8", "panic: 8"}, + {"bool", "true", "panic: true"}, + {"complex64", "8 + 16i", "panic: (+8.000000e+000+1.600000e+001i)"}, + {"complex128", "8+16i", "panic: (+8.000000e+000+1.600000e+001i)"}, + {"string", `"test"`, "panic: test"}} { + + b := bytes.Buffer{} + fmt.Fprintf(&b, fn, tc.Type, tc.Input) + + err = ioutil.WriteFile(tmpFile, b.Bytes(), 0644) + if err != nil { + log.Fatal(err) + } + + cmd := exec.Command("go", "run", tmpFile) + var buf bytes.Buffer + cmd.Stdout = &buf + cmd.Stderr = &buf + cmd.Env = os.Environ() + cmd.Run() // ignore err as we expect a panic + + out := buf.Bytes() + panicIdx := bytes.Index(out, []byte("panic: ")) + if panicIdx == -1 { + log.Fatalf("expected a panic in output for %s, got: %s", tc.Type, out) + } + eolIdx := bytes.IndexByte(out[panicIdx:], '\n') + panicIdx + if panicIdx == -1 { + log.Fatalf("expected a newline in output for %s after the panic, got: %s", tc.Type, out) + } + out = out[0:eolIdx] + if string(out) != tc.Expect { + log.Fatalf("expected '%s' for panic(%s(%s)), got %s", tc.Expect, tc.Type, tc.Input, out) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19667.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19667.go new file mode 100644 index 0000000000000000000000000000000000000000..4b0925add24719c43e003ab05596ddcf997fd877 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19667.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2017 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. + +// Make sure we don't crash when reporting this error. + +package p + +func f() { + if err := http.ListenAndServe( // GCCGO_ERROR "undefined name" +} // ERROR "unexpected }, expected expression|expected operand|missing .*\)|expected .*;|expected .*{" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19671.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19671.go new file mode 100644 index 0000000000000000000000000000000000000000..475c3e0afc628cbe3e6ae08211f51bc646727751 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19671.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2017 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. + +// Used to crash when compiling assignments involving [0]T, +// where T is not SSA-able. + +package a + +func f() { + var i int + arr := [0][2]int{} + arr[i][0] = 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19678.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19678.go new file mode 100644 index 0000000000000000000000000000000000000000..81ef331ee65ea36584f32f2fa0a29d8fbd0ab2e1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19678.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2017 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. + +// Used to crash when compiling functions containing +// forward refs in dead code. + +package p + +var f func(int) + +func g() { +l1: + i := 0 + goto l1 +l2: + f(i) + goto l2 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19679.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19679.go new file mode 100644 index 0000000000000000000000000000000000000000..636b27ffef863327c96f411ab1a7dbf73b4b9db4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19679.go @@ -0,0 +1,38 @@ +// compile + +// Copyright 2017 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. + +// Used to crash when a type switch was present in dead code +// in an inlineable function. + +package p + +func Then() { + var i interface{} + if false { + switch i.(type) { + } + } +} + +func Else() { + var i interface{} + if true { + _ = i + } else { + switch i.(type) { + } + } +} + +func Switch() { + var i interface{} + switch 5 { + case 3: + switch i.(type) { + } + case 5: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19696.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19696.go new file mode 100644 index 0000000000000000000000000000000000000000..4cb2789091cade6e0de0ad8323cda45d3d9f5c1e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19696.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2017 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. + +// Used to crash when compiling assignments involving [0]T, +// where T is not SSA-able. + +package p + +type s struct { + a, b, c, d, e int +} + +func f() { + var i int + arr := [0]s{} + arr[i].a++ +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19699.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19699.go new file mode 100644 index 0000000000000000000000000000000000000000..8000a5224ffba9b9d443462063c8bc838f6a2968 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19699.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19699b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19699b.go new file mode 100644 index 0000000000000000000000000000000000000000..32ed30fd2bae2a068881151aec0a2f566a5c32ad --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19699b.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2017 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 p + +func f() bool { + if false { + } else { + return true + } +} // ERROR "missing return( at end of function)?" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19705.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19705.go new file mode 100644 index 0000000000000000000000000000000000000000..6157945bbbce954f267adde5637b00dadea084a7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19705.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2017 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 p + +func f1() { + f2() +} + +func f2() { + if false { + _ = func() {} + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19710.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19710.go new file mode 100644 index 0000000000000000000000000000000000000000..c42ea7c2ceda16d6f963ac4f8c00418a25bb3bba --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19710.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2017 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. + +// Issue 19710: mishandled defer delete(...) + +package main + +func main() { + if n := len(f()); n != 0 { + println("got", n, "want 0") + panic("bad defer delete") + } +} + +func f() map[int]bool { + m := map[int]bool{} + for i := 0; i < 3; i++ { + m[i] = true + defer delete(m, i) + } + return m +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19743.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19743.go new file mode 100644 index 0000000000000000000000000000000000000000..5089cc61d82babe6feb50d3b6bd8b640ed8238d6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19743.go @@ -0,0 +1,31 @@ +// errorcheck -0 -m -l + +// Copyright 2017 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 foo + +// Escape analysis needs to treat the uintptr-typed reflect.*Header fields as pointers. + +import ( + "reflect" + "unsafe" +) + +type immutableBytes []byte + +// Bug was failure to leak param b. +func toString(b immutableBytes) string { // ERROR "leaking param: b$" + var s string + if len(b) == 0 { + return s + } + + strHeader := (*reflect.StringHeader)(unsafe.Pointer(&s)) + strHeader.Data = (*reflect.SliceHeader)(unsafe.Pointer(&b)).Data + + l := len(b) + strHeader.Len = l + return s +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19764.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19764.go new file mode 100644 index 0000000000000000000000000000000000000000..26fb00be2d0fce681361adb58b4922621911bd1b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19764.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2017 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. + +// Issue 19764: test that the linker's trampoline insertion +// pass is happy with direct calls to interface wrappers that +// may be defined in multiple packages. +package ignore diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19783.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19783.go new file mode 100644 index 0000000000000000000000000000000000000000..8d6494eaa4768a0d37b99bfdc35dc3213a40cda3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19783.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2017 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 p + +func Spin() { +l1: + for true { + goto l1 + l2: + if true { + goto l2 + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19799.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19799.go new file mode 100644 index 0000000000000000000000000000000000000000..cb675d7b0d1ee5e4a3e2b799d9fbda4326429119 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19799.go @@ -0,0 +1,71 @@ +// run + +// Copyright 2017 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 + +import ( + "os" + "runtime" +) + +func foo(x int) int { + return x + 1 +} + +func test() { + defer func() { + if r := recover(); r != nil { + pcs := make([]uintptr, 10) + n := runtime.Callers(0, pcs) + pcs = pcs[:n] + frames := runtime.CallersFrames(pcs) + for { + f, more := frames.Next() + if f.Function == "main.foo" { + println("did not expect to see call to foo in stack trace") + os.Exit(1) + } + if !more { + break + } + } + } + }() + var v []int + foo(v[0]) +} + +func bar(x ...int) int { + return x[0] + 1 +} + +func testVariadic() { + defer func() { + if r := recover(); r != nil { + pcs := make([]uintptr, 10) + n := runtime.Callers(0, pcs) + pcs = pcs[:n] + frames := runtime.CallersFrames(pcs) + for { + f, more := frames.Next() + if f.Function == "main.bar" { + println("did not expect to see call to bar in stack trace") + os.Exit(1) + } + if !more { + break + } + } + } + }() + var v []int + bar(v[0]) +} + +func main() { + test() + testVariadic() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19880.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19880.go new file mode 100644 index 0000000000000000000000000000000000000000..57cdc93ef6629ee611226353c17e830a87a30b28 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19880.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 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 p + +type T struct { + f [1]int +} + +func a() { + _ = T // ERROR "type T is not an expression|invalid use of type|not an expression" +} + +func b() { + var v [len(T{}.f)]int // ok + _ = v +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19911.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19911.go new file mode 100644 index 0000000000000000000000000000000000000000..af7f59814e1a06dad11331066e713d148b49fdda --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19911.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2017 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 + +import ( + "fmt" + "strings" +) + +type ET struct{} + +func (*ET) Error() string { return "err" } + +func main() { + check("false", fmt.Sprintf("(*ET)(nil) == error(nil): %v", (*ET)(nil) == error(nil))) + check("true", fmt.Sprintf("(*ET)(nil) != error(nil): %v", (*ET)(nil) != error(nil))) + + nilET := (*ET)(nil) + nilError := error(nil) + + check("false", fmt.Sprintf("nilET == nilError: %v", nilET == nilError)) + check("true", fmt.Sprintf("nilET != nilError: %v", nilET != nilError)) +} + +func check(want, gotfull string) { + got := gotfull[strings.Index(gotfull, ": ")+len(": "):] + if got != want { + panic("want " + want + " got " + got + " from " + gotfull) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19947.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19947.go new file mode 100644 index 0000000000000000000000000000000000000000..752cfc6bf602d08fd91acd78fa8af812f925349e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19947.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2017 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. + +// No double error on ideal -> float{32,64} conversion overflow + +package issue19947 + +var _ = float32(1) * 1e200 // ERROR "constant 1e\+200 overflows float32|1e200 .* overflows float32" +var _ = float64(1) * 1e500 // ERROR "constant 1e\+500 overflows float64|1e500 .* overflows float64" + +var _ = complex64(1) * 1e200 // ERROR "constant 1e\+200 overflows complex64|1e200 .* overflows complex64" +var _ = complex128(1) * 1e500 // ERROR "constant 1e\+500 overflows complex128|1e500 .* overflows complex128" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue19977.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue19977.go new file mode 100644 index 0000000000000000000000000000000000000000..6e4a9cc422c7181698b0563f871c6b9783e5bceb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue19977.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 19977: multiple error messages when type switching on an undefined + +package foo + +func Foo() { + switch x := a.(type) { // ERROR "undefined: a|reference to undefined name .*a" + default: + _ = x + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20014.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20014.go new file mode 100644 index 0000000000000000000000000000000000000000..e186aa1d072b3fdcfa1a4550a4d0a9bb47c5651a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20014.go @@ -0,0 +1,7 @@ +// runindir -goexperiment fieldtrack -ldflags -k=main.fieldTrackInfo + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20014.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue20014.out new file mode 100644 index 0000000000000000000000000000000000000000..3f79c77ba3cf4ce0fe639ff6ad2c08cfc3870728 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20014.out @@ -0,0 +1,6 @@ +0 +0 +0 +0 +issue20014.dir/a.T.X +main.T.X diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20029.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20029.go new file mode 100644 index 0000000000000000000000000000000000000000..db3f8aa5ddd00353874dd6dafe576ad15f1d4b70 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20029.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2017 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. + +// Issue 20029: make sure we zero at VARKILLs of +// ambiguously live variables. +// The ambiguously live variable here is the hiter +// for the inner range loop. + +package main + +import "runtime" + +func f(m map[int]int) { +outer: + for i := 0; i < 10; i++ { + for k := range m { + if k == 5 { + continue outer + } + } + runtime.GC() + break + } + runtime.GC() +} +func main() { + m := map[int]int{1: 2, 2: 3, 3: 4} + f(m) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20097.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20097.go new file mode 100644 index 0000000000000000000000000000000000000000..236a1bd40a73d5b841068ad855b199cf42d77688 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20097.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2017 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. + +// Issue 20097: ensure that we CSE multiple Select ops with +// the same underlying type + +package main + +type T int64 + +func f(x, y int64) (int64, T) { + a := x / y + b := T(x) / T(y) + return a, b +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20145.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20145.go new file mode 100644 index 0000000000000000000000000000000000000000..67ba5aee9a81e1e7cf2a39ad3393ec643802b77e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20145.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2017 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. + +// Issue 20145: some func types weren't dowidth-ed by the front end, +// leading to races in the backend. + +package p + +func f() { + _ = (func())(nil) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20162.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20162.go new file mode 100644 index 0000000000000000000000000000000000000000..41f156ef143ad935e7117e68e0974b87064fe8d7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20162.go @@ -0,0 +1,16 @@ +// compile -c=4 + +// Copyright 2017 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. + +// Issue 20162: embedded interfaces weren't dowidth-ed by the front end, +// leading to races in the backend. + +package p + +func Foo() { + _ = (make([]func() interface { + M(interface{}) + }, 1)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20174.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20174.go new file mode 100644 index 0000000000000000000000000000000000000000..a9c1fd8daff7a7db29b7a559eaafb2581510ed02 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20174.go @@ -0,0 +1,18 @@ +// compile -c=2 + +// Copyright 2017 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. + +// Issue 20174: failure to typecheck contents of *T in the frontend. + +package p + +func f() { + _ = (*interface{})(nil) // interface{} here used to not have its width calculated going into backend + select { + case _ = <-make(chan interface { + M() + }, 1): + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20185.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20185.go new file mode 100644 index 0000000000000000000000000000000000000000..3f79b75ed5403b58ad94e9d9043d35862ca65542 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20185.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 20185: type switching on untyped values (e.g. nil or consts) +// caused an internal compiler error. + +package p + +func F() { + switch t := nil.(type) { // ERROR "cannot type switch on non-interface value|not an interface" + default: + _ = t + } +} + +const x = 1 + +func G() { + switch t := x.(type) { // ERROR "cannot type switch on non-interface value|declared and not used|not an interface" + default: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20227.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20227.go new file mode 100644 index 0000000000000000000000000000000000000000..f59923106dd9521bc239ce81060908b9e710cd00 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20227.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 20227: panic while constructing constant "1i/1e-600000000" + +package p + +var _ = 1 / 1e-600000000i // ERROR "division by zero" +var _ = 1i / 1e-600000000 // ERROR "division by zero" +var _ = 1i / 1e-600000000i // ERROR "division by zero" + +var _ = 1 / (1e-600000000 + 1e-600000000i) // ERROR "division by zero" +var _ = 1i / (1e-600000000 + 1e-600000000i) // ERROR "division by zero" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20232.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20232.go new file mode 100644 index 0000000000000000000000000000000000000000..846843dccbae01d87a4ce54ea10a6a96078f0042 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20232.go @@ -0,0 +1,12 @@ +// errorcheck -d=panic + +// Copyright 2017 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 x = 6e5518446744 // ERROR "malformed constant: 6e5518446744" +const _ = x * x +const _ = 1e-1000000000 +const _ = 1e+1000000000 // ERROR "malformed constant: 1e\+1000000000" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20233.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20233.go new file mode 100644 index 0000000000000000000000000000000000000000..4dec4e458beacd856385a723ef5be63f58fed243 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20233.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 20233: panic while formatting an error message + +package p + +var f = func(...A) // ERROR "undefined: A" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20245.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20245.go new file mode 100644 index 0000000000000000000000000000000000000000..20258231d1207a12ded45c58dcab414ca7b929ca --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20245.go @@ -0,0 +1,11 @@ +// errorcheck -d=panic + +// Copyright 2017 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. + +// Issue 20245: panic while formatting an error message + +package p + +var e = interface{ I1 } // ERROR "undefined: I1" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20250.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20250.go new file mode 100644 index 0000000000000000000000000000000000000000..34184c48158e9682b9cfb0cd871c314265d49553 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20250.go @@ -0,0 +1,26 @@ +// errorcheck -0 -live -l + +//go:build !goexperiment.cgocheck2 + +// Copyright 2017 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. + +// Issue 20250: liveness differed with concurrent compilation +// due to propagation of addrtaken to outer variables for +// closure variables. + +package p + +type T struct { + s [2]string +} + +func f(a T) { // ERROR "live at entry to f: a$" + var e interface{} // ERROR "stack object e interface \{\}$" + func() { // ERROR "live at entry to f.func1: &e a$" + e = a.s // ERROR "live at call to convT: &e$" "stack object a T$" + }() + // Before the fix, both a and e were live at the previous line. + _ = e +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20298.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20298.go new file mode 100644 index 0000000000000000000000000000000000000000..7572a6b6c55411fbe9262dca29b354d064f8a75b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20298.go @@ -0,0 +1,32 @@ +// errorcheck -e=0 + +// Copyright 2017 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. + +// Issue 20298: "imported and not used" error report order was non-deterministic. +// This test works by limiting the number of errors (-e=0) +// and checking that the errors are all at the beginning. + +package p + +import ( + "bufio" // ERROR "imported and not used" + "bytes" // ERROR "imported and not used" + "crypto/x509" // ERROR "imported and not used" + "flag" // ERROR "imported and not used" + "fmt" // ERROR "imported and not used" + "io" // ERROR "imported and not used" + "io/ioutil" // ERROR "imported and not used" + "log" // ERROR "imported and not used" + "math" // ERROR "imported and not used" + "math/big" // ERROR "imported and not used" "too many errors" + "math/bits" + "net" + "net/http" + "os" + "path" + "path/filepath" + "regexp" + "strings" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20333.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20333.go new file mode 100644 index 0000000000000000000000000000000000000000..8202ab3e2215467a36405b0a7ca232220edb376e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20333.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2017 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. + +// Issue 20333: early checkwidth of [...] arrays led to compilation errors. + +package main + +import "fmt" + +func main() { + fmt.Println(&[...]string{"abc", "def", "ghi"}) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20335.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20335.go new file mode 100644 index 0000000000000000000000000000000000000000..185c2f06ea7a68c698876c7e23a3da7a82c18a09 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20335.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2017 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. + +// Issue 20335: don't reorder loads with stores. +// This test should fail on the ssacheck builder +// without the fix in the CL that added this file. +// TODO: check the generated assembly? + +package a + +import "sync/atomic" + +func f(p, q *int32) bool { + x := *q + return atomic.AddInt32(p, 1) == x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20415.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20415.go new file mode 100644 index 0000000000000000000000000000000000000000..71f34bba57cbf4d17076a75a94045accc04b633e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20415.go @@ -0,0 +1,33 @@ +// errorcheck + +// Copyright 2017 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. + +// Make sure redeclaration errors report correct position. + +package p + +// 1 +var f byte + +var f interface{} // ERROR "issue20415.go:12: previous declaration|redefinition|f redeclared" + +func _(f int) { +} + +// 2 +var g byte + +func _(g int) { +} + +var g interface{} // ERROR "issue20415.go:20: previous declaration|redefinition|g redeclared" + +// 3 +func _(h int) { +} + +var h byte + +var h interface{} // ERROR "issue20415.go:31: previous declaration|redefinition|h redeclared" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20529.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20529.go new file mode 100644 index 0000000000000000000000000000000000000000..118365d6bed6ca09498e966f2ef28176cbd39b41 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20529.go @@ -0,0 +1,21 @@ +// errorcheck + +//go:build amd64 + +// Copyright 2017 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. + +// Issue 20529: Large stack frames caused compiler panics. +// Only tested on amd64 because the test only makes sense +// on a 64 bit system, and it is platform-agnostic, +// so testing one suffices. + +package p + +import "runtime" + +func f() { // GC_ERROR "stack frame too large" + x := [][]int{1e9: []int{}} + runtime.KeepAlive(x) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20530.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20530.go new file mode 100644 index 0000000000000000000000000000000000000000..51f0bd8e39d1632f0973b9bb2026b35a977c0d8f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20530.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2017 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 + +var a uint8 + +//go:noinline +func f() { + b := int8(func() int32 { return -1 }()) + a = uint8(b) + if int32(a) != 255 { + // Failing case prints 'got 255 expected 255' + println("got", a, "expected 255") + } +} + +//go:noinline +func g() { + b := int8(func() uint32 { return 0xffffffff }()) + a = uint8(b) + if int32(a) != 255 { + // Failing case prints 'got 255 expected 255' + println("got", a, "expected 255") + } +} + +func main() { + f() + g() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20602.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20602.go new file mode 100644 index 0000000000000000000000000000000000000000..d4d513b0509163bb954accfe4382f80edf961e0e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20602.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2017 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. + +// Verify that the correct (not implicitly dereferenced) +// type is reported in the error message. + +package p + +var p = &[1]complex128{0} +var _ = real(p) // ERROR "type \*\[1\]complex128|argument must have complex type" +var _ = imag(p) // ERROR "type \*\[1\]complex128|argument must have complex type" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20682.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20682.go new file mode 100644 index 0000000000000000000000000000000000000000..8000a5224ffba9b9d443462063c8bc838f6a2968 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20682.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20739.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20739.go new file mode 100644 index 0000000000000000000000000000000000000000..b71a25dc4242beb5919bc8502c3055198e25ef4e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20739.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2017 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 p + +func F() { + var x struct { + x *int + w [1e9][1e9][1e9][0]*int + y *int + } + println(&x) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20749.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20749.go new file mode 100644 index 0000000000000000000000000000000000000000..2ca1f43d02c6fb2881e8b2077e19b65d54d8958c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20749.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2017 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 p + +// Verify that the compiler complains even if the array +// has length 0. +var a [0]int +var _ = a[2:] // ERROR "invalid slice index 2|array index out of bounds|index 2 out of bounds" + +var b [1]int +var _ = b[2:] // ERROR "invalid slice index 2|array index out of bounds|index 2 out of bounds" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20780.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20780.go new file mode 100644 index 0000000000000000000000000000000000000000..f73e6d1f794bb39210965cdcaa22051c88faef96 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20780.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2018 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. + +// We have a limit of 1GB for stack frames. +// Make sure we include the callee args section. + +package main + +type Big = [400e6]byte + +func f() { // GC_ERROR "stack frame too large" + // Note: This test relies on the fact that we currently always + // spill function-results to the stack, even if they're so + // large that we would normally heap allocate them. If we ever + // improve the backend to spill temporaries to the heap, this + // test will probably need updating to find some new way to + // construct an overly large stack frame. + g(h(), h()) +} + +func g(Big, Big) +func h() Big diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20780b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20780b.go new file mode 100644 index 0000000000000000000000000000000000000000..8aba8548b87d89f2175cfd3ad210e804daf1b468 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20780b.go @@ -0,0 +1,63 @@ +// run -race + +//go:build cgo && linux && amd64 + +// Copyright 2021 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. + +// Test that CL 281293 doesn't interfere with race detector +// instrumentation. + +package main + +import "fmt" + +const N = 2e6 + +type Big = [N]int + +var sink interface{} + +func main() { + g(0, f(0)) + + x1 := f(1) + sink = &x1 + g(1, x1) + g(7, f(7)) + g(1, x1) + + x3 := f(3) + sink = &x3 + g(1, x1) + g(3, x3) + + h(f(0), x1, f(2), x3, f(4)) +} + +//go:noinline +func f(k int) (x Big) { + for i := range x { + x[i] = k*N + i + } + return +} + +//go:noinline +func g(k int, x Big) { + for i := range x { + if x[i] != k*N+i { + panic(fmt.Sprintf("x%d[%d] = %d", k, i, x[i])) + } + } +} + +//go:noinline +func h(x0, x1, x2, x3, x4 Big) { + g(0, x0) + g(1, x1) + g(2, x2) + g(3, x3) + g(4, x4) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20789.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20789.go new file mode 100644 index 0000000000000000000000000000000000000000..4e4eed42a7ff4bdcdf25f3118b5217b4d7547ed5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20789.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2017 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. + +// Make sure this doesn't crash the compiler. +// (This test should be part of the internal/syntax +// package, but we don't have a general test framework +// there yet, so put it here for now. See also #20800.) + +package e +func([<-chan<-[func u){go // ERROR "unexpected u" \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20811.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20811.go new file mode 100644 index 0000000000000000000000000000000000000000..96b61ec728912c4acc569c7f53e2da492878cd46 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20811.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2017 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. + +// Issue 20811: slice-in-bound check is lowered incorrectly on +// amd64p32. + +package main + +func main() { + i := g() + _ = "x"[int32(i)] + j := g() + _ = "x"[:int32(j)] +} + +//go:noinline +func g() int64 { + return 4398046511104 +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20812.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20812.go new file mode 100644 index 0000000000000000000000000000000000000000..d0df831dfddd53c479dbfd80c4d13d8aacf46625 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20812.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2017 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 p + +func f() { + _ = int("1") // ERROR "cannot convert|invalid type conversion" + _ = bool(0) // ERROR "cannot convert|invalid type conversion" + _ = bool("false") // ERROR "cannot convert|invalid type conversion" + _ = int(false) // ERROR "cannot convert|invalid type conversion" + _ = string(true) // ERROR "cannot convert|invalid type conversion" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20813.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20813.go new file mode 100644 index 0000000000000000000000000000000000000000..b147a8903ce9776a31b24fda9aa5f5f201de3931 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20813.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2017 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 p + +func f() { + 1 = 2 // ERROR "cannot assign to 1|invalid left hand side" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue20923.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue20923.go new file mode 100644 index 0000000000000000000000000000000000000000..5fd1ad8a46b07b09eddb382baeb0227dcb4b2e81 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue20923.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2018 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. + +// Issue 20923: gccgo failed to compile parenthesized select case expressions. + +package p + +func F(c chan bool) { + select { + case (<-c): + case _ = (<-c): + case _, _ = (<-c): + case (c) <- true: + default: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21048.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21048.go new file mode 100644 index 0000000000000000000000000000000000000000..e365a5e14fc937b566e9c135b574bcb4cde69600 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21048.go @@ -0,0 +1,72 @@ +// run + +// Copyright 2017 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. + +// Issue 21048: s390x merged address generation into stores +// to unaligned global variables. This resulted in an illegal +// instruction. + +package main + +type T struct { + _ [1]byte + a [2]byte // offset: 1 + _ [3]byte + b [2]uint16 // offset: 6 + _ [2]byte + c [2]uint32 // offset: 12 + _ [2]byte + d [2]int16 // offset: 22 + _ [2]byte + e [2]int32 // offset: 28 +} + +var Source, Sink T + +func newT() T { + return T{ + a: [2]byte{1, 2}, + b: [2]uint16{1, 2}, + c: [2]uint32{1, 2}, + d: [2]int16{1, 2}, + e: [2]int32{1, 2}, + } +} + +//go:noinline +func moves() { + Sink.a = Source.a + Sink.b = Source.b + Sink.c = Source.c + Sink.d = Source.d + Sink.e = Source.e +} + +//go:noinline +func loads() *T { + t := newT() + t.a = Source.a + t.b = Source.b + t.c = Source.c + t.d = Source.d + t.e = Source.e + return &t +} + +//go:noinline +func stores() { + t := newT() + Sink.a = t.a + Sink.b = t.b + Sink.c = t.c + Sink.d = t.d + Sink.e = t.e +} + +func main() { + moves() + loads() + stores() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21120.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21120.go new file mode 100644 index 0000000000000000000000000000000000000000..ea896ce8e1a788ec3d591416729609c522768d0c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21120.go @@ -0,0 +1,11 @@ +// rundir + +// Copyright 2017 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. + +// The compiler was using an incomplete symbol name for reflect name data, +// permitting an invalid merge in the linker, producing an incorrect +// exported flag bit. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21221.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21221.go new file mode 100644 index 0000000000000000000000000000000000000000..bd5a4b550eaa9d82bc30d0f72d7f10105adec2f1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21221.go @@ -0,0 +1,18 @@ +// run + +// Copyright 2018 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 + +import "unsafe" + +func main() { + if unsafe.Pointer(uintptr(0)) != unsafe.Pointer(nil) { + panic("fail") + } + if (*int)(unsafe.Pointer(uintptr(0))) != (*int)(nil) { + panic("fail") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21253.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21253.go new file mode 100644 index 0000000000000000000000000000000000000000..3531b2b81fdf17a2ed9f4f65c210caeac17ccbff --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21253.go @@ -0,0 +1,27 @@ +// compile + +// Copyright 2017 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. + +// Gccgo crashed compiling this code due to failing to finalize +// interfaces in the right order. + +package p + +type s1 struct { + f m + I +} + +type m interface { + Mm(*s2) +} + +type s2 struct { + *s1 +} + +type I interface { + MI() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21256.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21256.go new file mode 100644 index 0000000000000000000000000000000000000000..c845ec52b3876fc5a9a470c9ddecf8d71b0a2a04 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21256.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2017 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 + +var main = func() {} // ERROR "must be func|redefinition" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21273.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21273.go new file mode 100644 index 0000000000000000000000000000000000000000..77a1abad9bb3b7ad5306a8b84fc2f5f5e05f8ad2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21273.go @@ -0,0 +1,28 @@ +// errorcheck + +// Copyright 2017 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 + +type T0 T0 // ERROR "invalid recursive type" +type _ map[T0]int + +type T1 struct{ T1 } // ERROR "invalid recursive type" +type _ map[T1]int + +func f() { + type T2 T2 // ERROR "invalid recursive type" + type _ map[T2]int +} + +func g() { + type T3 struct{ T3 } // ERROR "invalid recursive type" + type _ map[T3]int +} + +func h() { + type T4 struct{ m map[T4]int } // ERROR "invalid map key" + type _ map[T4]int // GC_ERROR "invalid map key" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21317.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21317.go new file mode 100644 index 0000000000000000000000000000000000000000..cebfc0f52d67935f8d6228fca818804ccefd79bd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21317.go @@ -0,0 +1,57 @@ +// run + +//go:build !js && !wasip1 && gc + +// Copyright 2017 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. + +// As of "Mon 6 Nov 2017", run.go doesn't yet have proper +// column matching so instead match the output manually +// by exec-ing + +package main + +import ( + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "strings" +) + +func main() { + f, err := ioutil.TempFile("", "issue21317.go") + if err != nil { + log.Fatal(err) + } + fmt.Fprintf(f, ` +package main + +import "fmt" + +func main() { + n, err := fmt.Println(1) +} +`) + f.Close() + defer os.RemoveAll(f.Name()) + + // compile and test output + cmd := exec.Command("go", "tool", "compile", "-p=main", "-importcfg="+os.Getenv("STDLIB_IMPORTCFG"), f.Name()) + out, err := cmd.CombinedOutput() + if err == nil { + log.Fatalf("expected cmd/compile to fail") + } + wantErrs := []string{ + "7:9: n declared and not used", + "7:12: err declared and not used", + } + outStr := string(out) + for _, want := range wantErrs { + if !strings.Contains(outStr, want) { + log.Fatalf("failed to match %q\noutput: %q", want, outStr) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21576.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21576.go new file mode 100644 index 0000000000000000000000000000000000000000..d5bfc2859b74d3993baf4add8f7a57af67b80f54 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21576.go @@ -0,0 +1,63 @@ +// run + +//go:build !nacl && !js && !wasip1 && !gccgo + +// Copyright 2019 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. +// +// Ensure that deadlock detection can still +// run even with an import of "_ os/signal". + +package main + +import ( + "bytes" + "context" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "time" +) + +const prog = ` +package main + +import _ "os/signal" + +func main() { + c := make(chan int) + c <- 1 +} +` + +func main() { + dir, err := ioutil.TempDir("", "21576") + if err != nil { + log.Fatal(err) + } + defer os.RemoveAll(dir) + + file := filepath.Join(dir, "main.go") + if err := ioutil.WriteFile(file, []byte(prog), 0655); err != nil { + log.Fatalf("Write error %v", err) + } + + // Using a timeout of 1 minute in case other factors might slow + // down the start of "go run". See https://golang.org/issue/34836. + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + + cmd := exec.CommandContext(ctx, "go", "run", file) + output, err := cmd.CombinedOutput() + if err == nil { + log.Fatalf("Passed, expected an error") + } + + want := []byte("fatal error: all goroutines are asleep - deadlock!") + if !bytes.Contains(output, want) { + log.Fatalf("Unmatched error message %q:\nin\n%s\nError: %v", want, output, err) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21655.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21655.go new file mode 100644 index 0000000000000000000000000000000000000000..66d4e3a7f5ab51357f44452c56880c1ebde8d02d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21655.go @@ -0,0 +1,62 @@ +// compile + +// Copyright 2017 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. + +// Make sure assembly offsets don't get too large. + +// To trigger issue21655, the index offset needs to be small +// enough to fit into an int32 (to get rewritten to an ADDQconst) +// but large enough to overflow an int32 after multiplying by the stride. + +package main + +func f1(a []int64, i int64) int64 { + return a[i+1<<30] +} +func f2(a []int32, i int64) int32 { + return a[i+1<<30] +} +func f3(a []int16, i int64) int16 { + return a[i+1<<30] +} +func f4(a []int8, i int64) int8 { + return a[i+1<<31] +} +func f5(a []float64, i int64) float64 { + return a[i+1<<30] +} +func f6(a []float32, i int64) float32 { + return a[i+1<<30] +} + +// Note: Before the fix for issue 21655, f{1,2,5,6} made +// the compiler crash. f3 silently generated the wrong +// code, using an offset of -1<<31 instead of 1<<31. +// (This is due to the assembler accepting offsets +// like 0x80000000 and silently using them as +// signed 32 bit offsets.) +// f4 was ok, but testing it can't hurt. + +func f7(ss []*string, i int) string { + const offset = 3 << 29 // 3<<29 * 4 = 3<<31 = 1<<31 mod 1<<32. + if i > offset { + return *ss[i-offset] + } + return "" +} +func f8(ss []*string, i int) string { + const offset = 3<<29 + 10 + if i > offset { + return *ss[i-offset] + } + return "" +} +func f9(ss []*string, i int) string { + const offset = 3<<29 - 10 + if i > offset { + return *ss[i-offset] + } + return "" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21687.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21687.go new file mode 100644 index 0000000000000000000000000000000000000000..9b4c03feb3d61c1cbe10f69b60dc5e264ce39e88 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21687.go @@ -0,0 +1,68 @@ +// run + +// Copyright 2017 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. + +// Issue 21687: cmd/compile evaluates x twice in "x op= y", which was +// detectable if evaluating y affects x. + +package main + +func ptrs() (int, int) { + one := 1 + two := 2 + + x := &one + *x += func() int { + x = &two + return 0 + }() + + return one, two +} + +func slices() (int, int) { + one := []int{1} + two := []int{2} + + x := one + x[0] += func() int { + x = two + return 0 + }() + + return one[0], two[0] +} + +func maps() (int, int) { + one := map[int]int{0: 1} + two := map[int]int{0: 2} + + x := one + x[0] += func() int { + x = two + return 0 + }() + + return one[0], two[0] +} + +var tests = [...]func() (int, int){ + ptrs, + slices, + maps, +} + +func main() { + bad := 0 + for i, f := range tests { + if a, b := f(); a+b != 3 { + println(i, a, b) + bad++ + } + } + if bad != 0 { + panic(bad) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21709.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21709.go new file mode 100644 index 0000000000000000000000000000000000000000..20be10e7928021fb120204990a94e6a868378fb8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21709.go @@ -0,0 +1,37 @@ +// errorcheck -0 -l -m + +// Copyright 2017 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. + +// Issue 21709: range expression overly escapes. + +package p + +type S struct{} + +func (s *S) Inc() {} // ERROR "s does not escape" +var N int + +func F1() { + var s S + for i := 0; i < N; i++ { + fs := []func(){ // ERROR "\[\]func\(\){...} does not escape" + s.Inc, // ERROR "s.Inc does not escape" + } + for _, f := range fs { + f() + } + } +} + +func F2() { + var s S + for i := 0; i < N; i++ { + for _, f := range []func(){ // ERROR "\[\]func\(\){...} does not escape" + s.Inc, // ERROR "s.Inc does not escape" + } { + f() + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21770.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21770.go new file mode 100644 index 0000000000000000000000000000000000000000..2f07d640d98e64535007dd0dbb9dd01a4cd085e8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21770.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 21770: gccgo incorrectly accepts "p.f = 0" where p is **struct + +package p + +type PP **struct{ f int } + +func f() { + // anonymous type + var p **struct{ f int } + p.f = 0 // ERROR "field" + // named type + var p2 PP + p2.f = 0 // ERROR "field" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21808.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21808.go new file mode 100644 index 0000000000000000000000000000000000000000..d146200eaee7d53372fa4c9aab593264eb608e5d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21808.go @@ -0,0 +1,17 @@ +// run + +// Copyright 2017 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. + +// Make sure println() prints a blank line. + +package main + +import "fmt" + +func main() { + fmt.Println("A") + println() + fmt.Println("B") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21808.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue21808.out new file mode 100644 index 0000000000000000000000000000000000000000..655da036b23d6843b0cc803ed210fdc921ed1d12 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21808.out @@ -0,0 +1,3 @@ +A + +B diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21879.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21879.go new file mode 100644 index 0000000000000000000000000000000000000000..1029ca044b6a53d179d867548c1f60b517ad84ac --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21879.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2017 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 + +import ( + "runtime" +) + +func main() { + println(caller().frame.Function) + + // Used to erroneously print "main.call.name" instead of + // "main.main". + println(caller().name()) +} + +func caller() call { + var pcs [3]uintptr + n := runtime.Callers(1, pcs[:]) + frames := runtime.CallersFrames(pcs[:n]) + frame, _ := frames.Next() + frame, _ = frames.Next() + + return call{frame: frame} +} + +type call struct { + frame runtime.Frame +} + +func (c call) name() string { + return c.frame.Function +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21879.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue21879.out new file mode 100644 index 0000000000000000000000000000000000000000..066f1a838715bc77136e2668453f284300ab9da0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21879.out @@ -0,0 +1,2 @@ +main.main +main.main diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21882.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21882.go new file mode 100644 index 0000000000000000000000000000000000000000..f77e046960b6dddc11b5d6e3d4e295f8391286ed --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21882.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2017 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 p + +type T [2]T // ERROR "invalid recursive type" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21887.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21887.go new file mode 100644 index 0000000000000000000000000000000000000000..73c3f43596ff406d3ad4c6230231a30c59a19405 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21887.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2017 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. + +// Issue 21887: println(^uint(0)) fails to compile + +package main + +import "strconv" + +func main() { + if strconv.IntSize == 32 { + println(^uint(0)) + } else { + println(^uint32(0)) + } + + if strconv.IntSize == 64 { + println(^uint(0)) + } else { + println(^uint64(0)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21887.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue21887.out new file mode 100644 index 0000000000000000000000000000000000000000..664b67d742248ca1f9d455b8bcd1931fe10b9357 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21887.out @@ -0,0 +1,2 @@ +4294967295 +18446744073709551615 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21934.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21934.go new file mode 100644 index 0000000000000000000000000000000000000000..e9a430f18f98bbbd1e52910d8100bc8515f1e02c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21934.go @@ -0,0 +1,26 @@ +// errorcheck + +// Copyright 2019 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. + +// selector expression resolves incorrectly for defined +// pointer types. + +package main + +type E struct{ f int } +type T struct{ E } + +func (*T) f() int { return 0 } + +type P *T +type PP **T + +func main() { + var x P + _ = x.f // ERROR "x\.f undefined \(type P has no field or method f\)" + + var y PP + _ = y.f // ERROR "y\.f undefined \(type PP has no field or method f\)" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21963.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21963.go new file mode 100644 index 0000000000000000000000000000000000000000..996bd63d09d82de6bb1279d06d1798d91137b690 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21963.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2017 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 + +import ( + "fmt" + "runtime" +) + +//go:noinline +func f(x []int32, y *int8) int32 { + c := int32(int16(*y)) + runtime.GC() + return x[0] * c +} + +func main() { + var x = [1]int32{5} + var y int8 = -1 + if got, want := f(x[:], &y), int32(-5); got != want { + panic(fmt.Sprintf("wanted %d, got %d", want, got)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21979.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21979.go new file mode 100644 index 0000000000000000000000000000000000000000..c6575a3928a4175aceb3c562036c81635ff92c41 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21979.go @@ -0,0 +1,47 @@ +// errorcheck + +// Copyright 2019 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 p + +func f() { + _ = bool("") // ERROR "cannot convert .. \(.*untyped string.*\) to type bool|invalid type conversion" + _ = bool(1) // ERROR "cannot convert 1 \(.*untyped int.*\) to type bool|invalid type conversion" + _ = bool(1.0) // ERROR "cannot convert 1.* \(.*untyped float.*\) to type bool|invalid type conversion" + _ = bool(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(.*untyped complex.*\) to type bool|invalid type conversion" + + _ = string(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type string|invalid type conversion" + _ = string(-1) + _ = string(1.0) // ERROR "cannot convert 1.* \(.*untyped float.*\) to type string|invalid type conversion" + _ = string(-4 + 2i) // ERROR "cannot convert -4 \+ 2i \(.*untyped complex.*\) to type string|invalid type conversion" + + _ = int("") // ERROR "cannot convert .. \(.*untyped string.*\) to type int|invalid type conversion" + _ = int(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type int|invalid type conversion" + _ = int(-1) + _ = int(1) + _ = int(1.0) + _ = int(-4 + 2i) // ERROR "truncated to integer|cannot convert -4 \+ 2i \(.*untyped complex.*\) to type int" + + _ = uint("") // ERROR "cannot convert .. \(.*untyped string.*\) to type uint|invalid type conversion" + _ = uint(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type uint|invalid type conversion" + _ = uint(-1) // ERROR "constant -1 overflows uint|integer constant overflow|cannot convert -1 \(untyped int constant\) to type uint" + _ = uint(1) + _ = uint(1.0) + // types1 reports extra error "truncated to integer" + _ = uint(-4 + 2i) // ERROR "constant -4 overflows uint|truncated to integer|cannot convert -4 \+ 2i \(untyped complex constant.*\) to type uint" + + _ = float64("") // ERROR "cannot convert .. \(.*untyped string.*\) to type float64|invalid type conversion" + _ = float64(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type float64|invalid type conversion" + _ = float64(-1) + _ = float64(1) + _ = float64(1.0) + _ = float64(-4 + 2i) // ERROR "truncated to|cannot convert -4 \+ 2i \(.*untyped complex.*\) to type float64" + + _ = complex128("") // ERROR "cannot convert .. \(.*untyped string.*\) to type complex128|invalid type conversion" + _ = complex128(true) // ERROR "cannot convert true \(.*untyped bool.*\) to type complex128|invalid type conversion" + _ = complex128(-1) + _ = complex128(1) + _ = complex128(1.0) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue21988.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue21988.go new file mode 100644 index 0000000000000000000000000000000000000000..4dbf06ee315bf57dfefbf029810ce07283e88c67 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue21988.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 21988: panic on switch case with invalid value + +package p + +const X = Wrong(0) // ERROR "undefined: Wrong|undefined name .*Wrong" + +func _() { + switch 0 { + case X: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22063.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22063.go new file mode 100644 index 0000000000000000000000000000000000000000..8d84047e078e24c337f9570a52c6600ed8dd8509 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22063.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 22063: panic on interface switch case with invalid name + +package p + +const X = Wrong(0) // ERROR "undefined: Wrong|reference to undefined name .*Wrong" + +func _() { + switch interface{}(nil) { + case X: + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22076.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22076.go new file mode 100644 index 0000000000000000000000000000000000000000..b383a674e2f66b02d2bd53ca6306f23f92db45b1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22076.go @@ -0,0 +1,25 @@ +// compile + +// Copyright 2017 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. + +// Issue 22076: Couldn't use ":=" to declare names that refer to +// dot-imported symbols. + +package p + +import . "bytes" + +var _ Reader // use "bytes" import + +func f1() { + Buffer := 0 + _ = Buffer +} + +func f2() { + for Buffer := range []int{} { + _ = Buffer + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22083.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22083.go new file mode 100644 index 0000000000000000000000000000000000000000..a385102d08199fa52bb8e3556da1b68164629390 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22083.go @@ -0,0 +1,41 @@ +// run + +// Copyright 2017 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. + +// The compiler was panicking on the wrong line number, where +// the panic was occurring in an inlined call. + +package main + +import ( + "runtime/debug" + "strings" +) + +type Wrapper struct { + a []int +} + +func (w Wrapper) Get(i int) int { + return w.a[i] +} + +func main() { + defer func() { + e := recover() + if e == nil { + panic("bounds check didn't fail") + } + stk := string(debug.Stack()) + if !strings.Contains(stk, "issue22083.go:40") { + panic("wrong stack trace: " + stk) + } + }() + foo := Wrapper{a: []int{0, 1, 2}} + _ = foo.Get(0) + _ = foo.Get(1) + _ = foo.Get(2) + _ = foo.Get(3) // stack trace should mention this line +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22164.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22164.go new file mode 100644 index 0000000000000000000000000000000000000000..fad78e23e81b9a9b1f14b0f88775e93f48d8cb4c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22164.go @@ -0,0 +1,26 @@ +// errorcheck + +// Copyright 2017 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. + +// Test error recovery after missing closing parentheses in lists. + +package p + +func f() { + x := f(g() // ERROR "unexpected newline" + y := 1 +} + +func g() { +} + +func h() { + x := f(g() // ERROR "unexpected newline" +} + +func i() { + x := []int{1, 2, 3 // ERROR "unexpected newline" + y := 0 +} \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22198.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22198.go new file mode 100644 index 0000000000000000000000000000000000000000..c874c1caa100d0bf0fdf9a8c8846da71d9a1956a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22198.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2017 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 issue22198 + +func f(a *bool, b bool) { + if b { + return + } + c := '\n' + if b { + c = ' ' + } + *a = c == '\n' +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22200.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22200.go new file mode 100644 index 0000000000000000000000000000000000000000..37440d9bf0ec4e27f1373a8f383c1f6033cbed4f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22200.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2017 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 p + +func f1(x *[1<<30 - 1e6]byte) byte { + for _, b := range *x { + return b + } + return 0 +} +func f2(x *[1<<30 + 1e6]byte) byte { // GC_ERROR "stack frame too large" + for _, b := range *x { + return b + } + return 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22200b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22200b.go new file mode 100644 index 0000000000000000000000000000000000000000..7babeec84707938c099d429eeee199d9d001facf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22200b.go @@ -0,0 +1,28 @@ +// errorcheck + +//go:build !386 && !amd64p32 && !arm && !mips && !mipsle + +// Copyright 2017 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 p + +func f3(x *[1 << 31]byte) byte { // GC_ERROR "stack frame too large" + for _, b := range *x { + return b + } + return 0 +} +func f4(x *[1 << 32]byte) byte { // GC_ERROR "stack frame too large" + for _, b := range *x { + return b + } + return 0 +} +func f5(x *[1 << 33]byte) byte { // GC_ERROR "stack frame too large" + for _, b := range *x { + return b + } + return 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22305.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22305.go new file mode 100644 index 0000000000000000000000000000000000000000..ec432f9ae8967852454a5956a9b30815d71c3f76 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22305.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2017 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. + +// Issue 22305: gccgo failed to compile this file. + +package main + +var F func() [0]func() +var i = 2 +var B = F()[i] + +func main() {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22326.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22326.go new file mode 100644 index 0000000000000000000000000000000000000000..a675655b235af6b1c05df607d75912e5a78a4826 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22326.go @@ -0,0 +1,25 @@ +// run + +// Copyright 2019 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 + +var ( + _ = d + _ = f("_", c, b) + a = f("a") + b = f("b") + c = f("c") + d = f("d") +) + +func f(s string, rest ...int) int { + print(s) + return 0 +} + +func main() { + println() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22326.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue22326.out new file mode 100644 index 0000000000000000000000000000000000000000..f02043893cb5fa02ae500680282b8d9e04a6b714 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22326.out @@ -0,0 +1 @@ +abc_d diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22327.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22327.go new file mode 100644 index 0000000000000000000000000000000000000000..7b21d834029d843ab3df674e2d849dea378eb237 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22327.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2018 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. + +// Using a multi-result function as an argument to +// append should compile successfully. Previously there +// was a missing *int -> interface{} conversion that caused +// the compiler to ICE. + +package p + +func f() ([]interface{}, *int) { + return nil, nil +} + +var _ = append(f()) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22344.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22344.go new file mode 100644 index 0000000000000000000000000000000000000000..9f2a6e86428671222f329e965b7fc7b19cd3201a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22344.go @@ -0,0 +1,83 @@ +// compile + +// Copyright 2019 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. + +// Test iota inside a function in a ConstSpec is accepted +package main + +import ( + "unsafe" +) + +// iotas are usable inside closures in constant declarations (#22345) +const ( + _ = iota + _ = len([iota]byte{}) + _ = unsafe.Sizeof(iota) + _ = unsafe.Sizeof(func() { _ = iota }) + _ = unsafe.Sizeof(func() { var _ = iota }) + _ = unsafe.Sizeof(func() { const _ = iota }) + _ = unsafe.Sizeof(func() { type _ [iota]byte }) + _ = unsafe.Sizeof(func() { func() int { return iota }() }) +) + +// verify inner and outer const declarations have distinct iotas +const ( + zero = iota + one = iota + _ = unsafe.Sizeof(func() { + var x [iota]int // [2]int + var y [iota]int // [2]int + const ( + Zero = iota + One + Two + _ = unsafe.Sizeof([iota - 1]int{} == x) // assert types are equal + _ = unsafe.Sizeof([iota - 2]int{} == y) // assert types are equal + _ = unsafe.Sizeof([Two]int{} == x) // assert types are equal + ) + var z [iota]int // [2]int + _ = unsafe.Sizeof([2]int{} == z) // assert types are equal + }) + three = iota // the sequence continues +) + +var _ [three]int = [3]int{} // assert 'three' has correct value + +func main() { + + const ( + _ = iota + _ = len([iota]byte{}) + _ = unsafe.Sizeof(iota) + _ = unsafe.Sizeof(func() { _ = iota }) + _ = unsafe.Sizeof(func() { var _ = iota }) + _ = unsafe.Sizeof(func() { const _ = iota }) + _ = unsafe.Sizeof(func() { type _ [iota]byte }) + _ = unsafe.Sizeof(func() { func() int { return iota }() }) + ) + + const ( + zero = iota + one = iota + _ = unsafe.Sizeof(func() { + var x [iota]int // [2]int + var y [iota]int // [2]int + const ( + Zero = iota + One + Two + _ = unsafe.Sizeof([iota - 1]int{} == x) // assert types are equal + _ = unsafe.Sizeof([iota - 2]int{} == y) // assert types are equal + _ = unsafe.Sizeof([Two]int{} == x) // assert types are equal + ) + var z [iota]int // [2]int + _ = unsafe.Sizeof([2]int{} == z) // assert types are equal + }) + three = iota // the sequence continues + ) + + var _ [three]int = [3]int{} // assert 'three' has correct value +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22351.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22351.go new file mode 100644 index 0000000000000000000000000000000000000000..e46a0fb20183763b23448a86df52debec7ac639e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22351.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2017 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 + +import "unsafe" + +const _ = uint64(unsafe.Offsetof(T{}.F)) // ERROR "undefined" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22389.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22389.go new file mode 100644 index 0000000000000000000000000000000000000000..81e6d94e65d4321e1206b5c7f7254f7a10726644 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22389.go @@ -0,0 +1,18 @@ +// errorcheck -d=panic + +// Copyright 2017 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 p + +type Foo struct{} + +func (f *Foo) Call(cb func(*Foo)) { + cb(f) +} + +func main() { + f := &Foo{} + f.Call(func(f) {}) // ERROR "f .*is not a type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22429.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22429.go new file mode 100644 index 0000000000000000000000000000000000000000..289b434a74ced95b0619a58b52174ee1aff54462 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22429.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2017 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. + +// Make sure SSA->assembly pass can handle SP as an index register. + +package p + +type T struct { + a,b,c,d float32 +} + +func f(a *[8]T, i,j,k int) float32 { + b := *a + return b[i].a + b[j].b + b[k].c +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22458.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22458.go new file mode 100644 index 0000000000000000000000000000000000000000..5c899295771dacd11776990d3a9d40bb88670229 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22458.go @@ -0,0 +1,26 @@ +// compile + +// Copyright 2017 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. + +// Make sure KeepAlive introduces a use of the spilled variable. + +package main + +import "runtime" + +type node struct { + next *node +} + +var x bool + +func main() { + var head *node + for x { + head = &node{head} + } + + runtime.KeepAlive(head) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22581.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22581.go new file mode 100644 index 0000000000000000000000000000000000000000..2b637f2ec6208c0c6ae38626f134cc4a4ac23ad8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22581.go @@ -0,0 +1,27 @@ +// errorcheck + +// Copyright 2017 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 p + +func f() { + if i := g()); i == j { // ERROR "unexpected \)" + } + + if i == g()] { // ERROR "unexpected \]" + } + + switch i := g()); i { // ERROR "unexpected \)" + } + + switch g()] { // ERROR "unexpected \]" + } + + for i := g()); i < y; { // ERROR "unexpected \)" + } + + for g()] { // ERROR "unexpected \]" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22605.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22605.go new file mode 100644 index 0000000000000000000000000000000000000000..9e726f353cbc1327a9ce9a0061a57d9344f11271 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22605.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2017 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. + +// We were picking up a special noalg type from typelinks. + +package main + +import "reflect" + +func f(m map[string]int) int { + return m["a"] +} + +func g(m map[[8]string]int) int { + t := reflect.ArrayOf(8, reflect.TypeOf("")) + a := reflect.New(t).Elem() + return m[a.Interface().([8]string)] +} + +func main() { + m := map[[8]string]int{} + g(m) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22660.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22660.go new file mode 100644 index 0000000000000000000000000000000000000000..10622033f0dc8d87564ae0024f49840c08c08138 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22660.go @@ -0,0 +1,47 @@ +// run + +//go:build !js && !wasip1 && gc + +// Copyright 2017 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 + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "strings" +) + +func main() { + f, err := ioutil.TempFile("", "issue22660.go") + if err != nil { + log.Fatal(err) + } + f.Close() + defer os.Remove(f.Name()) + + // path must appear in error messages even if we strip them with -trimpath + path := filepath.Join("users", "xxx", "go") + var src bytes.Buffer + fmt.Fprintf(&src, "//line %s:1\n", filepath.Join(path, "foo.go")) + + if err := ioutil.WriteFile(f.Name(), src.Bytes(), 0660); err != nil { + log.Fatal(err) + } + + out, err := exec.Command("go", "tool", "compile", "-p=p", fmt.Sprintf("-trimpath=%s", path), f.Name()).CombinedOutput() + if err == nil { + log.Fatalf("expected compiling %s to fail", f.Name()) + } + + if !strings.HasPrefix(string(out), path) { + log.Fatalf("expected full path (%s) in error message, got:\n%s", path, out) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22662.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22662.go new file mode 100644 index 0000000000000000000000000000000000000000..a1f00bfac310499c1403f44f8a9703fe5840b8d4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22662.go @@ -0,0 +1,46 @@ +// run + +// Copyright 2018 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. + +// Verify effect of various line directives. +// TODO: check columns + +package main + +import ( + "fmt" + "runtime" +) + +func check(file string, line int) { + _, f, l, ok := runtime.Caller(1) + if !ok { + panic("runtime.Caller(1) failed") + } + if f != file || l != line { + panic(fmt.Sprintf("got %s:%d; want %s:%d", f, l, file, line)) + } +} + +func main() { +//-style line directives +//line :1 + check("??", 1) // no file specified +//line foo.go:1 + check("foo.go", 1) +//line bar.go:10:20 + check("bar.go", 10) +//line :11:22 + check("bar.go", 11) // no file, but column specified => keep old filename + +/*-style line directives */ +/*line :1*/ check("??", 1) // no file specified +/*line foo.go:1*/ check("foo.go", 1) +/*line bar.go:10:20*/ check("bar.go", 10) +/*line :11:22*/ check("bar.go", 11) // no file, but column specified => keep old filename + + /*line :10*/ check("??", 10); /*line foo.go:20*/ check("foo.go", 20); /*line :30:1*/ check("foo.go", 30) + check("foo.go", 31) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22662b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22662b.go new file mode 100644 index 0000000000000000000000000000000000000000..a58a2e0a1534d7dffcd03944bb597a98c7038cf9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22662b.go @@ -0,0 +1,62 @@ +// run + +//go:build !js && !wasip1 && gc + +// Copyright 2018 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. + +// Verify the impact of line directives on error positions and position formatting. + +package main + +import ( + "io/ioutil" + "log" + "os" + "os/exec" + "strings" +) + +// Each of these tests is expected to fail (missing package clause) +// at the position determined by the preceding line directive. +var tests = []struct { + src, pos string +}{ + {"//line :10\n", ":10:"}, // no filename means no filename + {"//line :10:4\n", "filename:10:4"}, // no filename means use existing filename + {"//line foo.go:10\n", "foo.go:10:"}, // no column means don't print a column + {"//line foo.go:10:4\n", "foo.go:10:4:"}, // column means print a column + {"//line foo.go:10:4\n\n", "foo.go:11:1:"}, // relative columns start at 1 after newline + + {"/*line :10*/", ":10:"}, + {"/*line :10:4*/", "filename:10:4"}, + {"/*line foo.go:10*/", "foo.go:10:"}, + {"/*line foo.go:10:4*/", "foo.go:10:4:"}, + {"/*line foo.go:10:4*/\n", "foo.go:11:1:"}, +} + +func main() { + f, err := ioutil.TempFile("", "issue22662b.go") + if err != nil { + log.Fatal(err) + } + f.Close() + defer os.Remove(f.Name()) + + for _, test := range tests { + if err := ioutil.WriteFile(f.Name(), []byte(test.src), 0660); err != nil { + log.Fatal(err) + } + + out, err := exec.Command("go", "tool", "compile", "-p=p", f.Name()).CombinedOutput() + if err == nil { + log.Fatalf("expected compiling\n---\n%s\n---\nto fail", test.src) + } + + errmsg := strings.Replace(string(out), f.Name(), "filename", -1) // use "filename" instead of actual (long) filename + if !strings.HasPrefix(errmsg, test.pos) { + log.Fatalf("%q: got %q; want position %q", test.src, errmsg, test.pos) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22683.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22683.go new file mode 100644 index 0000000000000000000000000000000000000000..47c7f6513d9f3f1d6fd3367a62d086df439c80d9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22683.go @@ -0,0 +1,30 @@ +// run + +// Copyright 2017 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 + +import ( + "fmt" +) + +type foo struct { + bar [1]*int +} + +func main() { + ch := make(chan foo, 2) + var a int + var b [1]*int + b[0] = &a + ch <- foo{bar: b} + close(ch) + + for v := range ch { + for i := 0; i < 1; i++ { + fmt.Println(v.bar[0] != nil) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22683.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue22683.out new file mode 100644 index 0000000000000000000000000000000000000000..27ba77ddaf61532f217964734769a42cdabc17dc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22683.out @@ -0,0 +1 @@ +true diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22781.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22781.go new file mode 100644 index 0000000000000000000000000000000000000000..5ad82398bbc332f40c80b28f4a06511f3f5434d5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22781.go @@ -0,0 +1,29 @@ +// run + +// Copyright 2017 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 + +import "runtime/debug" + +type T struct { + // >= 16 bytes to avoid tiny alloc. + a, b int +} + +func main() { + debug.SetGCPercent(1) + for i := 0; i < 100000; i++ { + m := make(map[*T]struct{}, 0) + for j := 0; j < 20; j++ { + // During the call to mapassign_fast64, the key argument + // was incorrectly treated as a uint64. If the stack was + // scanned during that call, the only pointer to k was + // missed, leading to *k being collected prematurely. + k := new(T) + m[k] = struct{}{} + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22794.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22794.go new file mode 100644 index 0000000000000000000000000000000000000000..636af26e844f9829fdcf78b80b061ffa1ca36581 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22794.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2017 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 + +type it struct { + Floats bool + inner string +} + +func main() { + i1 := it{Floats: true} + if i1.floats { // ERROR "(type it .* field or method floats, but does have Floats)|undefined field or method" + } + i2 := &it{floats: false} // ERROR "(but does have Floats)|unknown field|declared and not used" + _ = &it{InneR: "foo"} // ERROR "(but does have inner)|unknown field" + _ = i2 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22822.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22822.go new file mode 100644 index 0000000000000000000000000000000000000000..9483c9cab0ab1c7b6b401531dea514cc18402bf9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22822.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2018 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. + +// Check that calling a function shadowing a built-in provides a good +// error message. + +package main + +func F() { + slice := []int{1, 2, 3} + _ = slice + len := int(2) + println(len(slice)) // ERROR "cannot call non-function len .type int., declared at LINE-1|expected function|cannot call non-function len" + const iota = 1 + println(iota(slice)) // ERROR "cannot call non-function iota .type int., declared at LINE-1|expected function|cannot call non-function iota" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22877.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22877.go new file mode 100644 index 0000000000000000000000000000000000000000..284b6807eb644b0f4dff102f4cdbad7148e3ef84 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22877.go @@ -0,0 +1,7 @@ +// builddir + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22881.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22881.go new file mode 100644 index 0000000000000000000000000000000000000000..645f2d4b87d5e2514630b627576ec42cc6636868 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22881.go @@ -0,0 +1,117 @@ +// run + +// Copyright 2017 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. + +// Test to make sure RHS is evaluated before map insert is started. +// The RHS panics in all of these cases. + +package main + +import "fmt" + +func main() { + for i, f := range []func(map[int]int){ + f0, f1, f2, f3, f4, f5, f6, f7, f8, + } { + m := map[int]int{} + func() { // wrapper to scope the defer. + defer func() { + recover() + }() + f(m) // Will panic. Shouldn't modify m. + fmt.Printf("RHS didn't panic, case f%d\n", i) + }() + if len(m) != 0 { + fmt.Printf("map insert happened, case f%d\n", i) + } + } + + // Append slice. + for i, f := range []func(map[int][]int){ + fa0, fa1, fa2, fa3, + } { + m := map[int][]int{} + func() { // wrapper to scope the defer. + defer func() { + recover() + }() + f(m) // Will panic. Shouldn't modify m. + fmt.Printf("RHS didn't panic, case fa%d\n", i) + }() + if len(m) != 0 { + fmt.Printf("map insert happened, case fa%d\n", i) + } + } +} + +func f0(m map[int]int) { + var p *int + m[0] = *p +} + +func f1(m map[int]int) { + var p *int + m[0] += *p +} + +func f2(m map[int]int) { + var p *int + sink, m[0] = sink, *p +} + +func f3(m map[int]int) { + var p *chan int + m[0], sink = <-(*p) +} + +func f4(m map[int]int) { + var p *interface{} + m[0], sink = (*p).(int) +} + +func f5(m map[int]int) { + var p *map[int]int + m[0], sink = (*p)[0] +} + +func f6(m map[int]int) { + var z int + m[0] /= z +} + +func f7(m map[int]int) { + var a []int + m[0] = a[0] +} + +func f8(m map[int]int) { + var z int + m[0] %= z +} + +func fa0(m map[int][]int) { + var p *int + m[0] = append(m[0], *p) +} + +func fa1(m map[int][]int) { + var p *int + sink, m[0] = !sink, append(m[0], *p) +} + +func fa2(m map[int][]int) { + var p *int + m[0], _ = append(m[0], 0), *p +} + +func fa3(m map[int][]int) { + // OSLICE has similar in-place-reassignment + // optimizations as OAPPEND, but we need to make sure + // to *not* optimize them, because we can't guarantee + // the slice indices are within bounds. + m[0] = m[0][:1] +} + +var sink bool diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22904.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22904.go new file mode 100644 index 0000000000000000000000000000000000000000..02459c6a4e80201541dec58f37028a63d2f00947 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22904.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2017 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. + +// Issue 22904: Make sure the compiler emits a proper error message about +// invalid recursive types rather than crashing. + +package p + +type a struct{ b } // ERROR "invalid recursive type" +type b struct{ a } // GCCGO_ERROR "invalid recursive type" + +var x interface{} + +func f() { + x = a{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22921.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22921.go new file mode 100644 index 0000000000000000000000000000000000000000..cdd77fb24f2fdedd58bbfa2bb0cd6eb49602b6c8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22921.go @@ -0,0 +1,18 @@ +// errorcheck -d=panic + +// Copyright 2020 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 + +import "bytes" + +type _ struct{ bytes.nonexist } // ERROR "unexported|undefined" + +type _ interface{ bytes.nonexist } // ERROR "unexported|undefined|expected signature or type name" + +func main() { + var _ bytes.Buffer + var _ bytes.buffer // ERROR "unexported|undefined" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22941.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22941.go new file mode 100644 index 0000000000000000000000000000000000000000..c3732c311b75f5a3b24749ddd578a8ddd5281651 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22941.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue22962.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue22962.go new file mode 100644 index 0000000000000000000000000000000000000000..8000a5224ffba9b9d443462063c8bc838f6a2968 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue22962.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23017.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23017.go new file mode 100644 index 0000000000000000000000000000000000000000..770c48ef26bd91b451a2da84732b899609a0782e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23017.go @@ -0,0 +1,113 @@ +// run + +// Copyright 2020 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. + +// assignment order in multiple assignments. +// See issue #23017 + +package main + +import "fmt" + +func main() {} + +func init() { + var m = map[int]int{} + var p *int + + defer func() { + recover() + check(1, len(m)) + check(42, m[2]) + }() + m[2], *p = 42, 2 +} + +func init() { + var m = map[int]int{} + p := []int{} + + defer func() { + recover() + check(1, len(m)) + check(2, m[2]) + }() + m[2], p[1] = 2, 2 +} + +func init() { + type P struct{ i int } + var m = map[int]int{} + var p *P + + defer func() { + recover() + check(1, len(m)) + check(3, m[2]) + }() + m[2], p.i = 3, 2 +} + +func init() { + type T struct{ i int } + var x T + p := &x + p, p.i = new(T), 4 + check(4, x.i) +} + +func init() { + var m map[int]int + var a int + var p = &a + + defer func() { + recover() + check(5, *p) + }() + *p, m[2] = 5, 2 +} + +var g int + +func init() { + var m map[int]int + defer func() { + recover() + check(0, g) + }() + m[0], g = 1, 2 +} + +func init() { + type T struct{ x struct{ y int } } + var x T + p := &x + p, p.x.y = new(T), 7 + check(7, x.x.y) + check(0, p.x.y) +} + +func init() { + type T *struct{ x struct{ y int } } + x := struct{ y int }{0} + var q T = &struct{ x struct{ y int } }{x} + p := q + p, p.x.y = nil, 7 + check(7, q.x.y) +} + +func init() { + x, y := 1, 2 + x, y = y, x + check(2, x) + check(1, y) +} + +func check(want, got int) { + if want != got { + panic(fmt.Sprintf("wanted %d, but got %d", want, got)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23093.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23093.go new file mode 100644 index 0000000000000000000000000000000000000000..0d3b13e633a509589abdc7bac608ac4d5c81a4a2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23093.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2017 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 p + +var f = func() { f() } // ERROR "initialization cycle|initialization expression for .*f.* depends upon itself" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23094.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23094.go new file mode 100644 index 0000000000000000000000000000000000000000..7c58cad5627e26c19a7abda84caef885e7fe2f13 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23094.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2018 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. + +// Verify that the array is reported in correct notation. + +package p + +var a [len(a)]int // ERROR "\[len\(a\)\]int|initialization cycle" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23116.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23116.go new file mode 100644 index 0000000000000000000000000000000000000000..1737fee2c8eaa8a7f0e29f8ae8ca0fc12ef06e99 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23116.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2018 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 p + +func f(x interface{}) { + switch x.(type) { + } + + switch t := x.(type) { // ERROR "declared and not used" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23179.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23179.go new file mode 100644 index 0000000000000000000000000000000000000000..8000a5224ffba9b9d443462063c8bc838f6a2968 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23179.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2017 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23188.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23188.go new file mode 100644 index 0000000000000000000000000000000000000000..c22434069c47b6654fb8ddcaf5dba6c9a1329d51 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23188.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2018 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. + +// Test order of evaluation of index operations. + +package main + +func main() { + arr := []int{1, 2} + + // The spec says that in an assignment statement the operands + // of all index expressions and pointer indirections on the + // left, and the expressions on the right, are evaluated in + // the usual order. The usual order means function calls and + // channel operations are done first. Then the assignments are + // carried out one at a time. The operands of an index + // expression include both the array and the index. So this + // evaluates as + // tmp1 := arr + // tmp2 := len(arr) - 1 + // tmp3 := len(arr) + // arr = arr[:tmp3-1] + // tmp1[tmp2] = 3 + arr, arr[len(arr)-1] = arr[:len(arr)-1], 3 + + if len(arr) != 1 || arr[0] != 1 || arr[:2][1] != 3 { + panic(arr) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23298.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23298.go new file mode 100644 index 0000000000000000000000000000000000000000..be00a8ec67faa0ed44a7eacad40ac82d470f8008 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23298.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2018 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 p + +type T string + +var ( + t = T("T") + r = []rune(t) +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23305.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23305.go new file mode 100644 index 0000000000000000000000000000000000000000..28f400c5e8168bf1efa5af38433c6809ff6bf9ce --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23305.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2018 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 mask1(a, b uint64) uint64 { + op1 := int32(a) + op2 := int32(b) + return uint64(uint32(op1 / op2)) +} + +var mask2 = mask1 + +func main() { + res1 := mask1(0x1, 0xfffffffeffffffff) + res2 := mask2(0x1, 0xfffffffeffffffff) + if res1 != 0xffffffff { + println("got", res1, "want", 0xffffffff) + panic("FAIL") + } + if res2 != 0xffffffff { + println("got", res2, "want", 0xffffffff) + panic("FAIL") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23311.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23311.go new file mode 100644 index 0000000000000000000000000000000000000000..128cf9d06ad6ed5c0d03c3889cf3ea483ad289af --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23311.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2018 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23414.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23414.go new file mode 100644 index 0000000000000000000000000000000000000000..7ef3d831fd9a2e4456797184da80127c04c5c07c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23414.go @@ -0,0 +1,13 @@ +// compile + +// Copyright 2018 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 p + +var x struct{} + +func f() bool { + return x == x && x == x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23489.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23489.go new file mode 100644 index 0000000000000000000000000000000000000000..1e64af1903aff6e47d7b160d22e8efc9fc32b38a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23489.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2017 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. + +// Caused gccgo to issue a spurious compilation error. + +package main + +type T struct{} + +func (*T) Foo() {} + +type P = *T + +func main() { + var p P + p.Foo() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23504.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23504.go new file mode 100644 index 0000000000000000000000000000000000000000..77f3184149bd4ee0d59ef0cdda09c2dc965ffc81 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23504.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2018 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 p + +func f() { + var B bool + B2 := (B || B && !B) && !B + B3 := B2 || B + for (B3 || B2) && !B2 && B { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23521.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23521.go new file mode 100644 index 0000000000000000000000000000000000000000..159e03238c3ceab41de2e90b14dc0b8d1ab8229d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23521.go @@ -0,0 +1,43 @@ +// errorcheck -0 -m + +// Copyright 2018 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. + +// Issue 23521: improve early DCE for if without explicit else. + +package p + +//go:noinline +func nonleaf() {} + +const truth = true + +func f() int { // ERROR "can inline f" + if truth { + return 0 + } + // If everything below is removed, as it should, + // function f should be inlineable. + nonleaf() + for { + panic("") + } +} + +func g() int { // ERROR "can inline g" + return f() // ERROR "inlining call to f" +} + +func f2() int { // ERROR "can inline f2" + if !truth { + nonleaf() + } else { + return 0 + } + panic("") +} + +func g2() int { // ERROR "can inline g2" + return f2() // ERROR "inlining call to f2" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23522.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23522.go new file mode 100644 index 0000000000000000000000000000000000000000..cace86c8abb016c66ba030474812bf5d854b4645 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23522.go @@ -0,0 +1,46 @@ +// run + +// Copyright 2018 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 + +import ( + "math" +) + +type S struct { + u int64 + n int32 +} + +func F1(f float64) *S { + s := f + pf := math.Copysign(f, 1) + u := math.Floor(pf) + return &S{ + u: int64(math.Copysign(u, s)), + n: int32(math.Copysign((pf-u)*1e9, s)), + } +} + +func F2(f float64) *S { + s := f + f = math.Copysign(f, 1) + u := math.Floor(f) + return &S{ + u: int64(math.Copysign(u, s)), + n: int32(math.Copysign((f-u)*1e9, s)), + } +} + +func main() { + s1 := F1(-1) + s2 := F2(-1) + if *s1 != *s2 { + println("F1:", s1.u, s1.n) + println("F2:", s2.u, s2.n) + panic("different") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23536.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23536.go new file mode 100644 index 0000000000000000000000000000000000000000..07b5033d361187e68dce614037ea6b86f47b62b0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23536.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2022 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. + +// Test case where a slice of a user-defined byte type (not uint8 or byte) is +// converted to a string. Same for slice of runes. + +package main + +type MyByte byte + +type MyRune rune + +func main() { + var y []MyByte + _ = string(y) + + var z []MyRune + _ = string(z) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23545.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23545.go new file mode 100644 index 0000000000000000000000000000000000000000..d97f64af5a0ed4810376deabf5a9605492bc6dbf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23545.go @@ -0,0 +1,31 @@ +// run + +// Copyright 2018 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. + +// Issue 23545: gccgo didn't lower array comparison to +// proper equality function in some case. + +package main + +func main() { + if a := Get(); a != dummyID(1234) { + panic("FAIL") + } +} + +func dummyID(x int) [Size]interface{} { + var out [Size]interface{} + out[0] = x + return out +} + +const Size = 32 + +type OutputID [Size]interface{} + +//go:noinline +func Get() OutputID { + return dummyID(1234) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23546.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23546.go new file mode 100644 index 0000000000000000000000000000000000000000..818f0cd6bfaba8705fa01e877d04fd0a1c132ee0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23546.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2018 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. + +// Issue 23546: type..eq function not generated when +// DWARF is disabled. + +package main + +func main() { + use(f() == f()) +} + +func f() [2]interface{} { + var out [2]interface{} + return out +} + +//go:noinline +func use(bool) {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23586.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23586.go new file mode 100644 index 0000000000000000000000000000000000000000..c7c82b6c37ff37d6802b62c719588f93f058758a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23586.go @@ -0,0 +1,24 @@ +// errorcheck + +// Copyright 2018 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. + +// Test that we type-check deferred/go functions even +// if they are not called (a common error). Specifically, +// we don't want to see errors such as import or variable +// declared and not used. + +package p + +import ( + "fmt" + "math" +) + +func f() { + var i int + defer func() { fmt.Println() } // ERROR "must be function call" + go func() { _ = math.Sin(0) } // ERROR "must be function call" + go func() { _ = i} // ERROR "must be function call" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23587.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23587.go new file mode 100644 index 0000000000000000000000000000000000000000..9040767f8cb6261c83743a2f674edab1cd499e67 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23587.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2018 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 p + +func _(x int) { + _ = ~x // unary ~ permitted but the type-checker will complain +} + +func _(x int) { + _ = x ~ x // ERROR "unexpected ~ at end of statement" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23609.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23609.go new file mode 100644 index 0000000000000000000000000000000000000000..9130e8dd1621ec459fc5fd1c3ebec99c914bd2e4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23609.go @@ -0,0 +1,27 @@ +// errorcheck + +// Copyright 2018 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 + +type t1 struct { + t1f1 int + t1f2 int +} +type t2 struct { + t2f1 int + t2f2 int + t1 +} +type t3 struct { + t3f1 int + t2 +} + +var ( + _ = t2{t1f1: 600} // ERROR "cannot use promoted field t1.t1f1 in struct literal of type t2|unknown field" + _ = t3{t1f2: 800} // ERROR "cannot use promoted field t2.t1.t1f2 in struct literal of type t3|unknown field" + _ = t3{t2f1: 900} // ERROR "cannot use promoted field t2.t2f1 in struct literal of type t3|unknown field" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23664.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23664.go new file mode 100644 index 0000000000000000000000000000000000000000..715654be70deb59ae48009dd3d8d9b8b29d1808d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23664.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2018 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. + +// Verify error messages for incorrect if/switch headers. + +package p + +func f() { + if f() true { // ERROR "unexpected true, expected {" + } + + switch f() true { // ERROR "unexpected true, expected {" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23719.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23719.go new file mode 100644 index 0000000000000000000000000000000000000000..c97e63636c06f6cdc0dbe6c4c662b214fd013aed --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23719.go @@ -0,0 +1,42 @@ +// run + +// Copyright 2018 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 main() { + v1 := [2]int32{-1, 88} + v2 := [2]int32{-1, 99} + if v1 == v2 { + panic("bad comparison") + } + + w1 := [2]int16{-1, 88} + w2 := [2]int16{-1, 99} + if w1 == w2 { + panic("bad comparison") + } + x1 := [4]int16{-1, 88, 88, 88} + x2 := [4]int16{-1, 99, 99, 99} + if x1 == x2 { + panic("bad comparison") + } + + a1 := [2]int8{-1, 88} + a2 := [2]int8{-1, 99} + if a1 == a2 { + panic("bad comparison") + } + b1 := [4]int8{-1, 88, 88, 88} + b2 := [4]int8{-1, 99, 99, 99} + if b1 == b2 { + panic("bad comparison") + } + c1 := [8]int8{-1, 88, 88, 88, 88, 88, 88, 88} + c2 := [8]int8{-1, 99, 99, 99, 99, 99, 99, 99} + if c1 == c2 { + panic("bad comparison") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23732.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23732.go new file mode 100644 index 0000000000000000000000000000000000000000..79b60e26df0db0162be417384e4bfc7dced6e0ed --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23732.go @@ -0,0 +1,42 @@ +// errorcheck + +// Copyright 2018 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. + +// Issue 23732: Give better details about which struct +// initializer has the wrong number of values. + +package main + +type Foo struct { + A int + B int + C interface{} + Bar +} + +type Bar struct { + A string +} + +func main() { + _ = Foo{ // GCCGO_ERROR "too few expressions" + 1, + 2, + 3, + } // GC_ERROR "too few values in" + + _ = Foo{ + 1, + 2, + 3, + Bar{"A", "B"}, // ERROR "too many values in|too many expressions" + } + + _ = Foo{ // GCCGO_ERROR "too few expressions" + 1, + 2, + Bar{"A", "B"}, // ERROR "too many values in|too many expressions" + } // GC_ERROR "too few values in" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23734.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23734.go new file mode 100644 index 0000000000000000000000000000000000000000..dd5869b8f00390916b0f493bf5acc2427110ece2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23734.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2018 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 main() { + m := map[interface{}]int{} + k := []int{} + + mustPanic(func() { + _ = m[k] + }) + mustPanic(func() { + _, _ = m[k] + }) + mustPanic(func() { + delete(m, k) + }) +} + +func mustPanic(f func()) { + defer func() { + r := recover() + if r == nil { + panic("didn't panic") + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23780.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23780.go new file mode 100644 index 0000000000000000000000000000000000000000..71fc2d9ed6f3a035eb5b73c18ba5108afddc861f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23780.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2018 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 p + +func f() { + _ = []byte{1 << 30: 1} +} + +func g() { + sink = []byte{1 << 30: 1} +} + +var sink []byte diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23781.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23781.go new file mode 100644 index 0000000000000000000000000000000000000000..194795132133119f2cd2a461011c79bd0f544ba8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23781.go @@ -0,0 +1,11 @@ +// compile + +//go:build amd64 + +// 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 p + +var _ = []int{1 << 31: 1} // ok on machines with 64bit int diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23812.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23812.go new file mode 100644 index 0000000000000000000000000000000000000000..0a40deb212e8e5a885165e91c2c6a528379b9a73 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23812.go @@ -0,0 +1,34 @@ +// run + +// Copyright 2018 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 + +import "fmt" + +func main() { + want := int32(0x3edae8) + got := foo(1) + if want != got { + panic(fmt.Sprintf("want %x, got %x", want, got)) + } +} + +func foo(a int32) int32 { + return shr1(int32(shr2(int64(0x14ff6e2207db5d1f), int(a))), 4) +} + +func shr1(n int32, m int) int32 { return n >> uint(m) } + +func shr2(n int64, m int) int64 { + if m < 0 { + m = -m + } + if m >= 64 { + return n + } + + return n >> uint(m) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23814.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23814.go new file mode 100644 index 0000000000000000000000000000000000000000..25ed2322b6447f212e257c1338550f871d587ce7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23814.go @@ -0,0 +1,61 @@ +// run + +// Copyright 2022 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. + +// Examples from the language spec section on string conversions. + +package main + +func main() { + // 1 + _ = string('a') // "a" + _ = string(-1) // "\ufffd" == "\xef\xbf\xbd" + _ = string(0xf8) // "\u00f8" == "ø" == "\xc3\xb8" + + type myString string + _ = myString(0x65e5) // "\u65e5" == "日" == "\xe6\x97\xa5" + + // 2 + _ = string([]byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'}) // "hellø" + _ = string([]byte{}) // "" + _ = string([]byte(nil)) // "" + + type bytes []byte + _ = string(bytes{'h', 'e', 'l', 'l', '\xc3', '\xb8'}) // "hellø" + + type myByte byte + _ = string([]myByte{'w', 'o', 'r', 'l', 'd', '!'}) // "world!" + _ = myString([]myByte{'\xf0', '\x9f', '\x8c', '\x8d'}) // "🌍 + + // 3 + _ = string([]rune{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "白鵬翔" + _ = string([]rune{}) // "" + _ = string([]rune(nil)) // "" + + type runes []rune + _ = string(runes{0x767d, 0x9d6c, 0x7fd4}) // "\u767d\u9d6c\u7fd4" == "白鵬翔" + + type myRune rune + _ = string([]myRune{0x266b, 0x266c}) // "\u266b\u266c" == "♫♬" + _ = myString([]myRune{0x1f30e}) // "\U0001f30e" == "🌎 + + // 4 + _ = []byte("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} + _ = []byte("") // []byte{} + + _ = bytes("hellø") // []byte{'h', 'e', 'l', 'l', '\xc3', '\xb8'} + + _ = []myByte("world!") // []myByte{'w', 'o', 'r', 'l', 'd', '!'} + _ = []myByte(myString("🌏")) // []myByte{'\xf0', '\x9f', '\x8c', '\x8f'} + + // 5 + _ = []rune(myString("白鵬翔")) // []rune{0x767d, 0x9d6c, 0x7fd4} + _ = []rune("") // []rune{} + + _ = runes("白鵬翔") // []rune{0x767d, 0x9d6c, 0x7fd4} + + _ = []myRune("♫♬") // []myRune{0x266b, 0x266c} + _ = []myRune(myString("🌐")) // []myRune{0x1f310} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23823.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23823.go new file mode 100644 index 0000000000000000000000000000000000000000..0d51f81098ce316d16e9bf16bf5dc7ad36fdac53 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23823.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2018 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 p + +type I1 = interface { + I2 +} + +// BAD: type loop should mention I1; see also #41669 +type I2 interface { // GC_ERROR "invalid recursive type: I2 refers to itself" + I1 // GCCGO_ERROR "invalid recursive interface" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23837.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23837.go new file mode 100644 index 0000000000000000000000000000000000000000..7ad50837f46443a3db9761da520fb90c89d88619 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23837.go @@ -0,0 +1,70 @@ +// run + +// Copyright 2018 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 + +//go:noinline +func f(p, q *struct{}) bool { + return *p == *q +} + +type T struct { + x struct{} + y int +} + +//go:noinline +func g(p, q *T) bool { + return p.x == q.x +} + +//go:noinline +func h(p, q func() struct{}) bool { + return p() == q() +} + +func fi(p, q *struct{}) bool { + return *p == *q +} + +func gi(p, q *T) bool { + return p.x == q.x +} + +func hi(p, q func() struct{}) bool { + return p() == q() +} + +func main() { + shouldPanic(func() { f(nil, nil) }) + shouldPanic(func() { g(nil, nil) }) + shouldPanic(func() { h(nil, nil) }) + shouldPanic(func() { fi(nil, nil) }) + shouldPanic(func() { gi(nil, nil) }) + shouldPanic(func() { hi(nil, nil) }) + n := 0 + inc := func() struct{} { + n++ + return struct{}{} + } + h(inc, inc) + if n != 2 { + panic("inc not called") + } + hi(inc, inc) + if n != 4 { + panic("inc not called") + } +} + +func shouldPanic(x func()) { + defer func() { + if recover() == nil { + panic("did not panic") + } + }() + x() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23868.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23868.go new file mode 100644 index 0000000000000000000000000000000000000000..af15c5fb39bf9b4830630a601a044a27d7b9636f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23868.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2022 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. + +// Crashed gccgo. + +package p + +var F func([0]int) int +var G func() [0]int + +var V = make([]int, F(G())) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23870.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23870.go new file mode 100644 index 0000000000000000000000000000000000000000..02aa2949c33d15d14c5056d6673e3ef1078fe425 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23870.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2022 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. + +// Crashed gccgo. + +package p + +var F func() [0]struct{ + A int +} + +var i int +var V = (F()[i]).A diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue23912.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue23912.go new file mode 100644 index 0000000000000000000000000000000000000000..05ffd6be298613f77238085de4c384b31912cd4f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue23912.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2018 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. + +// A couple of aliases cases that gccgo incorrectly gave errors for. + +package p + +func F1() { + type E = struct{} + type X struct{} + var x X + var y E = x + _ = y +} + +func F2() { + type E = struct{} + type S []E + type T []struct{} + type X struct{} + var x X + s := S{E{}} + t := T{struct{}{}} + _ = append(s, x) + _ = append(s, t[0]) + _ = append(s, t...) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24120.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24120.go new file mode 100644 index 0000000000000000000000000000000000000000..6c7d871b768859b57db6cf294880774f8af27f6d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24120.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2018 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 p + +var F func(int) + +func G() { + if F(func() int { return 1 }()); false { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24159.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24159.go new file mode 100644 index 0000000000000000000000000000000000000000..9397bdc84cc3279c382efb7a9133a78f6f2fa677 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24159.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2018 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 p + +type intAlias = int + +func f() { + switch interface{}(nil) { + case uint8(0): + case byte(0): // ERROR "duplicate case" + case int32(0): + case rune(0): // ERROR "duplicate case" + case int(0): + case intAlias(0): // ERROR "duplicate case" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24173.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24173.go new file mode 100644 index 0000000000000000000000000000000000000000..4c19e05ef0a72b23f57f8766b55515c676f8be21 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24173.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2018 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 p + +type arrayAlias = [10]int +type mapAlias = map[int]int +type sliceAlias = []int +type structAlias = struct{} + +func Exported() { + _ = arrayAlias{} + _ = mapAlias{} + _ = sliceAlias{} + _ = structAlias{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24187.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24187.go new file mode 100644 index 0000000000000000000000000000000000000000..f697968a098fa72b68d6d4ab9be30346d5bf5518 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24187.go @@ -0,0 +1,34 @@ +// run + +//go:build amd64p32 + +// Copyright 2018 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 + +import ( + "bytes" + "fmt" + "unsafe" +) + +func main() { + b := make([]byte, 128) + for i := range b { + b[i] = 1 + } + if bytes.IndexByte(b, 0) != -1 { + panic("found 0") + } + for i := range b { + b[i] = 0 + c := b + *(*int)(unsafe.Pointer(uintptr(unsafe.Pointer(&c)) + unsafe.Sizeof(uintptr(0)))) = 1<<31 - 1 + if bytes.IndexByte(c, 0) != i { + panic(fmt.Sprintf("missing 0 at %d\n", i)) + } + b[i] = 1 + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24339.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24339.go new file mode 100644 index 0000000000000000000000000000000000000000..4d54e3877f60dc1de83080eea23b086c996a1cdf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24339.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2018 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 p + +// Use a different line number for each token so we can +// check that the error message appears at the correct +// position. +var _ = struct{}{ /*line :20:1*/foo /*line :21:1*/: /*line :22:1*/0 } + + + + + + + +// ERROR "unknown field foo" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24419.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24419.go new file mode 100644 index 0000000000000000000000000000000000000000..73b7783e07740f6eda7bc2a632d4b8abb7d441fa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24419.go @@ -0,0 +1,51 @@ +// run + +// Copyright 2018 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 + +import ( + "bytes" + "strings" +) + +func growstack(n int) { + if n > 0 { + growstack(n - 1) + } +} + +func main() { + c := make(chan struct{}) + go compare(c) + go equal(c) + go indexByte(c) + go indexByteString(c) + <-c + <-c + <-c + <-c +} + +func compare(c chan struct{}) { + defer bytes.Compare(nil, nil) + growstack(10000) + c <- struct{}{} +} +func equal(c chan struct{}) { + defer bytes.Equal(nil, nil) + growstack(10000) + c <- struct{}{} +} +func indexByte(c chan struct{}) { + defer bytes.IndexByte(nil, 0) + growstack(10000) + c <- struct{}{} +} +func indexByteString(c chan struct{}) { + defer strings.IndexByte("", 0) + growstack(10000) + c <- struct{}{} +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24449.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24449.go new file mode 100644 index 0000000000000000000000000000000000000000..b236645103961b30da8d5db7f2c1bf255c096276 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24449.go @@ -0,0 +1,62 @@ +// run + +// Copyright 2018 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 + +import ( + "sync/atomic" +) + +var cnt32 int32 + +//go:noinline +func test32(a, b []int) bool { + // Try to generate flag value, issue atomic + // adds and then re-use the flag value to see if + // the atomic add has clobbered them. + atomic.AddInt32(&cnt32, 1) + if len(a) == len(b) { + atomic.AddInt32(&cnt32, 2) + } + atomic.AddInt32(&cnt32, 4) + if len(a) >= len(b) { + atomic.AddInt32(&cnt32, 8) + } + if len(a) <= len(b) { + atomic.AddInt32(&cnt32, 16) + } + return atomic.LoadInt32(&cnt32) == 31 +} + +var cnt64 int64 + +//go:noinline +func test64(a, b []int) bool { + // Try to generate flag value, issue atomic + // adds and then re-use the flag value to see if + // the atomic add has clobbered them. + atomic.AddInt64(&cnt64, 1) + if len(a) == len(b) { + atomic.AddInt64(&cnt64, 2) + } + atomic.AddInt64(&cnt64, 4) + if len(a) >= len(b) { + atomic.AddInt64(&cnt64, 8) + } + if len(a) <= len(b) { + atomic.AddInt64(&cnt64, 16) + } + return atomic.LoadInt64(&cnt64) == 31 +} + +func main() { + if !test32([]int{}, []int{}) { + panic("test32") + } + if !test64([]int{}, []int{}) { + panic("test64") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24470.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24470.go new file mode 100644 index 0000000000000000000000000000000000000000..5b7b2b5adf2b534f1be6b1adeaec8ae295788c19 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24470.go @@ -0,0 +1,16 @@ +// errorcheck -d=panic + +// Copyright 2018 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. + +// Verify that we get "use of .(type) outside type switch" +// before any other (misleading) errors. Test case from issue. + +package p + +func f(i interface{}) { + if x, ok := i.(type); ok { // ERROR "assignment mismatch|outside type switch" + _ = x + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24488.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24488.go new file mode 100644 index 0000000000000000000000000000000000000000..b3deab48228d84c52fc02e6cea4354aa4ff95280 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24488.go @@ -0,0 +1,38 @@ +// run + +// Copyright 2018 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 + +import ( + "runtime" + "strings" +) + +type Func func() + +func (f Func) Foo() { + if f != nil { + f() + } +} + +func (f Func) Bar() { + if f != nil { + f() + } + buf := make([]byte, 4000) + n := runtime.Stack(buf, true) + s := string(buf[:n]) + if strings.Contains(s, "-fm") { + panic("wrapper present in stack trace:\n" + s) + } +} + +func main() { + foo := Func(func() {}) + foo = foo.Bar + foo.Foo() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24491a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24491a.go new file mode 100644 index 0000000000000000000000000000000000000000..1f748186042cea8a8b5a8cd4099720669fbe4aac --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24491a.go @@ -0,0 +1,96 @@ +// run + +// Copyright 2020 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. + +// This test makes sure unsafe-uintptr arguments are handled correctly. + +package main + +import ( + "runtime" + "unsafe" +) + +var done = make(chan bool, 1) + +func setup() unsafe.Pointer { + s := "ok" + runtime.SetFinalizer(&s, func(p *string) { *p = "FAIL" }) + return unsafe.Pointer(&s) +} + +//go:noinline +//go:uintptrescapes +func test(s string, p, q uintptr, rest ...uintptr) int { + runtime.GC() + runtime.GC() + + if *(*string)(unsafe.Pointer(p)) != "ok" { + panic(s + ": p failed") + } + if *(*string)(unsafe.Pointer(q)) != "ok" { + panic(s + ": q failed") + } + for _, r := range rest { + if *(*string)(unsafe.Pointer(r)) != "ok" { + panic(s + ": r[i] failed") + } + } + + done <- true + return 0 +} + +//go:noinline +func f() int { + return test("return", uintptr(setup()), uintptr(setup()), uintptr(setup()), uintptr(setup())) +} + +type S struct{} + +//go:noinline +//go:uintptrescapes +func (S) test(s string, p, q uintptr, rest ...uintptr) int { + return test(s, p, q, rest...) +} + +func main() { + test("normal", uintptr(setup()), uintptr(setup()), uintptr(setup()), uintptr(setup())) + <-done + + go test("go", uintptr(setup()), uintptr(setup()), uintptr(setup()), uintptr(setup())) + <-done + + func() { + defer test("defer", uintptr(setup()), uintptr(setup()), uintptr(setup()), uintptr(setup())) + }() + <-done + + func() { + for { + defer test("defer in for loop", uintptr(setup()), uintptr(setup()), uintptr(setup()), uintptr(setup())) + break + } + }() + <-done + + func() { + s := &S{} + defer s.test("method call", uintptr(setup()), uintptr(setup()), uintptr(setup()), uintptr(setup())) + }() + <-done + + func() { + s := &S{} + for { + defer s.test("defer method loop", uintptr(setup()), uintptr(setup()), uintptr(setup()), uintptr(setup())) + break + } + }() + <-done + + f() + <-done +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24491b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24491b.go new file mode 100644 index 0000000000000000000000000000000000000000..142d798500b76208bde23e09567511d6c0380171 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24491b.go @@ -0,0 +1,46 @@ +// run + +// Copyright 2020 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. + +// This test makes sure unsafe-uintptr arguments are not +// kept alive longer than expected. + +package main + +import ( + "runtime" + "unsafe" +) + +var done = make(chan bool) + +func setup() unsafe.Pointer { + s := "ok" + runtime.SetFinalizer(&s, func(p *string) { close(done) }) + return unsafe.Pointer(&s) +} + +//go:noinline +//go:uintptrescapes +func before(p uintptr) int { + runtime.GC() + select { + case <-done: + panic("GC early") + default: + } + return 0 +} + +func after() int { + runtime.GC() + runtime.GC() + <-done + return 0 +} + +func main() { + _ = before(uintptr(setup())) + after() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24503.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24503.go new file mode 100644 index 0000000000000000000000000000000000000000..933ce70dbdc58423a36c9428c5a46c6180d0f5f2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24503.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2018 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. + +// Issue 24503: Handle == and != of addresses taken of symbols consistently. + +package main + +func test() string { + type test struct{} + o1 := test{} + o2 := test{} + if &o1 == &o2 { + return "equal" + } + if &o1 != &o2 { + return "unequal" + } + return "failed" +} + +func main() { + if test() == "failed" { + panic("expected either 'equal' or 'unequal'") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24547.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24547.go new file mode 100644 index 0000000000000000000000000000000000000000..47d94a9f9fbb417d330ac45c148e5600720b2466 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24547.go @@ -0,0 +1,46 @@ +// run + +// Copyright 2018 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. + +// When computing method sets with shadowed methods, make sure we +// compute whether a method promotion involved a pointer traversal +// based on the promoted method, not the shadowed method. + +package main + +import ( + "bytes" + "fmt" +) + +type mystruct struct { + f int +} + +func (t mystruct) String() string { + return "FAIL" +} + +func main() { + type deep struct { + mystruct + } + s := struct { + deep + *bytes.Buffer + }{ + deep{}, + bytes.NewBufferString("ok"), + } + + if got := s.String(); got != "ok" { + panic(got) + } + + var i fmt.Stringer = s + if got := i.String(); got != "ok" { + panic(got) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24651a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24651a.go new file mode 100644 index 0000000000000000000000000000000000000000..74bcbb1faecbb23df303bcd40ee8b7316238f598 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24651a.go @@ -0,0 +1,26 @@ +//errorcheck -0 -race -m -m + +//go:build (linux && amd64) || (linux && ppc64le) || (darwin && amd64) || (freebsd && amd64) || (netbsd && amd64) || (windows && amd64) + +// Copyright 2018 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 + +//go:norace +func Foo(x int) int { // ERROR "cannot inline Foo: marked go:norace with -race compilation$" + return x * (x + 1) * (x + 2) +} + +func Bar(x int) int { // ERROR "can inline Bar with cost .* as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$" + return x * (x + 1) * (x + 2) +} + +var x = 5 + +//go:noinline Provide a clean, constant reason for not inlining main +func main() { // ERROR "cannot inline main: marked go:noinline$" + println("Foo(", x, ")=", Foo(x)) + println("Bar(", x, ")=", Bar(x)) // ERROR "inlining call to Bar" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24651b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24651b.go new file mode 100644 index 0000000000000000000000000000000000000000..2af54fc4b53e52bf92480997bb94ee0e17e5cb48 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24651b.go @@ -0,0 +1,24 @@ +//errorcheck -0 -m -m + +// Copyright 2018 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 + +//go:norace +func Foo(x int) int { // ERROR "can inline Foo with cost .* as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$" + return x * (x + 1) * (x + 2) +} + +func Bar(x int) int { // ERROR "can inline Bar with cost .* as: func\(int\) int { return x \* \(x \+ 1\) \* \(x \+ 2\) }$" + return x * (x + 1) * (x + 2) +} + +var x = 5 + +//go:noinline Provide a clean, constant reason for not inlining main +func main() { // ERROR "cannot inline main: marked go:noinline$" + println("Foo(", x, ")=", Foo(x)) // ERROR "inlining call to Foo" + println("Bar(", x, ")=", Bar(x)) // ERROR "inlining call to Bar" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24693.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24693.go new file mode 100644 index 0000000000000000000000000000000000000000..3da6a81af32905aa705740aa504319f3ce10bb3e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24693.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2018 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24693.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue24693.out new file mode 100644 index 0000000000000000000000000000000000000000..79ebd0860f4905e20e884242810611636997eb71 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24693.out @@ -0,0 +1,2 @@ +ok +ok diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24760.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24760.go new file mode 100644 index 0000000000000000000000000000000000000000..cd6f124517a5c7381108086227f7694f71ce1a0b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24760.go @@ -0,0 +1,12 @@ +// compile + +// Copyright 2018 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 p + +import "unsafe" + +var _ = string([]byte(nil))[0] +var _ = uintptr(unsafe.Pointer(uintptr(1))) << 100 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24761.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24761.go new file mode 100644 index 0000000000000000000000000000000000000000..4b97663c3ccaf54a4f04bcc14fd828aadd2dd324 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24761.go @@ -0,0 +1,7 @@ +// compiledir -c=4 + +// Copyright 2018 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24763.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24763.go new file mode 100644 index 0000000000000000000000000000000000000000..623ab489e8e9adb043cc8eac52600e82bed7f0fa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24763.go @@ -0,0 +1,21 @@ +// run + +// Copyright 2018 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 main() { + var s uint + var x = interface{}(1< s, `"" > s`) + want(true, s > "", `s > ""`) + want(false, "" > e, `"" > e`) + want(false, e > "", `e > ""`) + + want(false, "" >= s, `"" >= s`) + want(true, s >= "", `s >= ""`) + want(true, "" >= e, `"" >= e`) + want(true, e >= "", `e >= ""`) + + want(false, "" == s, `"" == s`) + want(false, s == "", `s == ""`) + want(true, "" == e, `"" == e`) + want(true, e == "", `e == ""`) + + want(true, "" != s, `"" != s`) + want(true, s != "", `s != ""`) + want(false, "" != e, `"" != e`) + want(false, e != "", `e != ""`) + + if failed { + os.Exit(1) + } +} + +//go:noinline +func want(b bool, have bool, msg string) { + if b != have { + fmt.Println(msg) + failed = true + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24937.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24937.go new file mode 100644 index 0000000000000000000000000000000000000000..7d8460f61ece2f094414a49b9184238e3edc370f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24937.go @@ -0,0 +1,15 @@ +// run + +// Copyright 2018 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 main() { + x := []byte{'a'} + switch string(x) { + case func() string { x[0] = 'b'; return "b" }(): + panic("FAIL") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue24939.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue24939.go new file mode 100644 index 0000000000000000000000000000000000000000..0ae6f2b9f2600550e3aca2a0c41e9ce2a3329f7c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue24939.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2018 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 + +type T interface { + M(P) +} + +type M interface { + F() P +} + +type P = interface { + // The compiler cannot handle this case. Disabled for now. + // See issue #25838. + // I() M +} + +func main() {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25006.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25006.go new file mode 100644 index 0000000000000000000000000000000000000000..570fdca5c2d2dd38b68a9f2bc671b57864c86318 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25006.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2018 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 p + +func spin() { + var i int + var b bool + + switch 1 { + case 0: + i = 1 + } + switch 1 { + case i: + default: + i = 1 + b = !b && (b && !b) && b + } + switch false { + case false: + i = 3 + -i + switch 0 { + case 1 - i: + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25055.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25055.go new file mode 100644 index 0000000000000000000000000000000000000000..0e15a8e71fa215beebddbf51bacce8b2e16f3c70 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25055.go @@ -0,0 +1,7 @@ +// compiledir -c=2 + +// Copyright 2018 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25101.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25101.go new file mode 100644 index 0000000000000000000000000000000000000000..4fd6bed92b3273c46752682919127aadaaa7dcb4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25101.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2018 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. + +// Indexed export format must not crash when writing +// the anonymous parameter for m. + +package p + +var x interface { + m(int) +} + +var M = x.m diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25322.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25322.go new file mode 100644 index 0000000000000000000000000000000000000000..ee4ff53e2eedfdb5036785195d6a549a0139f91a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25322.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2018 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. + +// Missing zero extension when converting a float32 +// to a uint64. + +package main + +import ( + "fmt" + "math" +) + +func Foo(v float32) { + fmt.Printf("%x\n", uint64(math.Float32bits(v))) +} + +func main() { + Foo(2.0) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25322.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue25322.out new file mode 100644 index 0000000000000000000000000000000000000000..52f3f6a74518f6f135a1ee2207cbea4e03ff6e89 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25322.out @@ -0,0 +1 @@ +40000000 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25507.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25507.go new file mode 100644 index 0000000000000000000000000000000000000000..9143a73397d91466416e566623a8285299fc5c0c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25507.go @@ -0,0 +1,29 @@ +// errorcheck + +// Copyright 2018 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. + +// We have a limit of 1GB for stack frames. +// Test that we extend that limit to include large argument/return areas. +// Argument/return areas are part of the parent frame, not the frame itself, +// so they need to be handled separately. + +package main + +// >1GB to trigger failure, <2GB to work on 32-bit platforms. +type large struct { + b [1500000000]byte +} + +func (x large) f1() int { // GC_ERROR "stack frame too large" + return 5 +} + +func f2(x large) int { // GC_ERROR "stack frame too large" + return 5 +} + +func f3() (x large, i int) { // GC_ERROR "stack frame too large" + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25516.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25516.go new file mode 100644 index 0000000000000000000000000000000000000000..8326ef953f08cdcb1ca17d59371754a01b8d5771 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25516.go @@ -0,0 +1,26 @@ +// compile + +// Copyright 2018 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. + +// Make sure dead write barriers are handled correctly. + +package main + +func f(p **int) { + // The trick here is to eliminate the block containing the write barrier, + // but only after the write barrier branches are inserted. + // This requires some delicate code. + i := 0 + var b []bool + var s string + for true { + if b[i] { + var a []string + s = a[len(s)] + i = 0 + } + *p = nil + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25727.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25727.go new file mode 100644 index 0000000000000000000000000000000000000000..06b2e2cac7ddb9f95b379b4dcec9e69fb9cb10ca --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25727.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2018 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 + +import "net/http" + +var s = http.Server{} +var _ = s.doneChan // ERROR "s.doneChan undefined .cannot refer to unexported field or method doneChan.$|unexported field or method|s.doneChan undefined" +var _ = s.DoneChan // ERROR "s.DoneChan undefined .type http.Server has no field or method DoneChan.$|undefined field or method" +var _ = http.Server{tlsConfig: nil} // ERROR "unknown field tlsConfig in struct literal.+ .but does have TLSConfig.$|unknown field .?tlsConfig.? in .?http.Server|unknown field" +var _ = http.Server{DoneChan: nil} // ERROR "unknown field DoneChan in struct literal of type http.Server$|unknown field .?DoneChan.? in .?http.Server" + +type foo struct { + bar int +} + +var _ = &foo{bAr: 10} // ERROR "unknown field bAr in struct literal.+ .but does have bar.$|unknown field .?bAr.? in .?foo|unknown field" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25741.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25741.go new file mode 100644 index 0000000000000000000000000000000000000000..c76e9759460a3ca8e96eda36b3e24cbc0e2c389d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25741.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2018 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 + +var s []int + +func main() { + i := -1 + s[i] = 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25776.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25776.go new file mode 100644 index 0000000000000000000000000000000000000000..e05c0bce4d72398b1d526b1f13a1e2f4e5b81dc8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25776.go @@ -0,0 +1,99 @@ +// run + +// Copyright 2018 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 ( + Upper = true + blas_Upper = 121 + badTriangle = "bad triangle" +) + +// Triangular represents a triangular matrix. Triangular matrices are always square. +type Triangular interface { + // Triangular returns the number of rows/columns in the matrix and its + // orientation. + Tryangle() (mmmm int, kynd bool) + Triangle() (mmmm int, kynd bool) +} + +// blas64_Triangular represents a triangular matrix using the conventional storage scheme. +type blas64_Triangular struct { + Stride int + Uplo int +} + +// TriDense represents an upper or lower triangular matrix in dense storage +// format. +type TriDense struct { + mat blas64_Triangular +} + +func NewTriDense() *TriDense { + return &TriDense{ + mat: blas64_Triangular{ + Stride: 3, + Uplo: blas_Upper, + }, + } +} + +func (t *TriDense) isUpper() bool { + return isUpperUplo(t.mat.Uplo) +} + +func (t *TriDense) triKind() bool { + return isUpperUplo(t.mat.Uplo) +} + +func isUpperUplo(u int) bool { + switch u { + case blas_Upper: + return true + default: + panic(badTriangle) + } +} + +func (t *TriDense) IsZero() bool { + return t.mat.Stride == 0 +} + +//go:noinline +func (t *TriDense) ScaleTri(f float64, a Triangular) { + n, kind := a.Triangle() + if kind == false { + println("ScaleTri n, kind=", n, ", ", kind, " (FAIL, expected true)") + } +} + +//go:noinline +func (t *TriDense) ScaleTry(f float64, a Triangular) { + n, kind := a.Tryangle() + if kind == false { + println("ScaleTry n, kind=", n, ", ", kind, " (FAIL, expected true)") + } +} + +// Triangle failed (before fix) +func (t *TriDense) Triangle() (nnnn int, kind bool) { + return 3, !t.IsZero() && t.triKind() +} + +// Tryangle works -- difference is not-named output parameters. +func (t *TriDense) Tryangle() (int, bool) { + return 3, !t.IsZero() && t.triKind() +} + +func main() { + ta := NewTriDense() + n, kind := ta.Triangle() + if kind == false { + println(" main n, kind=", n, ", ", kind, " (FAIL, expected true)") + } + ta.ScaleTri(1, ta) + ta.ScaleTry(1, ta) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25897a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25897a.go new file mode 100644 index 0000000000000000000000000000000000000000..d4fa6c82feb507beb4831abbde6b5c201d784279 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25897a.go @@ -0,0 +1,51 @@ +// run + +// Copyright 2019 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. + +// Make sure the runtime can scan args of an unstarted goroutine +// which starts with a reflect-generated function. + +package main + +import ( + "reflect" + "runtime" +) + +const N = 100 + +func main() { + runtime.GOMAXPROCS(1) + // Run GC in a loop. This makes it more likely GC will catch + // an unstarted goroutine then if we were to GC after kicking + // everything off. + go func() { + for { + runtime.GC() + } + }() + c := make(chan bool, N) + for i := 0; i < N; i++ { + // Test both with an argument and without because this + // affects whether the compiler needs to generate a + // wrapper closure for the "go" statement. + f := reflect.MakeFunc(reflect.TypeOf(((func(*int))(nil))), + func(args []reflect.Value) []reflect.Value { + c <- true + return nil + }).Interface().(func(*int)) + go f(nil) + + g := reflect.MakeFunc(reflect.TypeOf(((func())(nil))), + func(args []reflect.Value) []reflect.Value { + c <- true + return nil + }).Interface().(func()) + go g() + } + for i := 0; i < N*2; i++ { + <-c + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25897b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25897b.go new file mode 100644 index 0000000000000000000000000000000000000000..09a9673a60fd3685e066f74d65e21119e8e52d89 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25897b.go @@ -0,0 +1,38 @@ +// run + +// Copyright 2019 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. + +// Make sure the runtime can scan args of an unstarted goroutine +// which starts with a reflect-generated function. + +package main + +import ( + "reflect" + "runtime" +) + +const N = 100 + +type T struct { +} + +func (t *T) Foo(c chan bool) { + c <- true +} + +func main() { + t := &T{} + runtime.GOMAXPROCS(1) + c := make(chan bool, N) + for i := 0; i < N; i++ { + f := reflect.ValueOf(t).MethodByName("Foo").Interface().(func(chan bool)) + go f(c) + } + runtime.GC() + for i := 0; i < N; i++ { + <-c + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25958.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25958.go new file mode 100644 index 0000000000000000000000000000000000000000..91358f83fe0ae0d8eee2eca082dd7356015509fc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25958.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2018 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 p + +// Verify that the "must be receive" error for "case done:" appears +// on the line of the case clause, not the line of the done declaration. + +func f(done chan struct{}) { + select { + case done: // ERROR "must be receive|expected .*<-.* or .*=|must be send or receive|not used" + case (chan struct{})(done): // ERROR "must be receive|expected .*<-.* or .*=|must be send or receive" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25966.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25966.go new file mode 100644 index 0000000000000000000000000000000000000000..7b5f2a7e4fb8a4b8d5fec011b6bb126dc2538a6c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25966.go @@ -0,0 +1,24 @@ +// compile -N + +// Copyright 2018 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. + +// Issue 25966: liveness code complains autotmp live on +// function entry. + +package p + +var F = []func(){ + func() func() { return (func())(nil) }(), +} + +var A = []int{} + +type ss struct { + string + float64 + i int +} + +var V = A[ss{}.i] diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25984.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25984.go new file mode 100644 index 0000000000000000000000000000000000000000..128cf9d06ad6ed5c0d03c3889cf3ea483ad289af --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25984.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2018 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue25993.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue25993.go new file mode 100644 index 0000000000000000000000000000000000000000..3253cd82f8b5e9feeb20166add76f075db97ef58 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue25993.go @@ -0,0 +1,21 @@ +// compile -d=ssa/check/on + +// Copyright 2018 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. + +// Issue 25993: SSA check fails on ARM. + +package p + +func f() { + var x int + var B0 bool + B0 = !B0 || B0 + if B0 && B0 { + x = -1 + } + var AI []int + var AB []bool + _ = AI[x] > 0 && AB[x] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26024.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26024.go new file mode 100644 index 0000000000000000000000000000000000000000..78877b21fe5de80815746f4c86cdd77812a7835c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26024.go @@ -0,0 +1,28 @@ +// compile +// Copyright 2018 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 r + +// f compiles into code where no stores remain in the two successors +// of a write barrier block; i.e., they are empty. Pre-fix, this +// results in an unexpected input to markUnsafePoints, that expects to +// see a pair of non-empty plain blocks. +func f() { + var i int + var s string + for len(s) < len(s) { + i++ + s = "a" + } + var b bool + var sa []string + for true { + sa = []string{""} + for b || i == 0 { + } + b = !b + _ = sa + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26043.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26043.go new file mode 100644 index 0000000000000000000000000000000000000000..fe32947b07ddb37b34fa13d2fccec4c092cf501e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26043.go @@ -0,0 +1,32 @@ +// compile + +// Copyright 2018 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. + +// This program results in a loop inferred to increment +// j by 0, causing bounds check elimination to attempt +// something%0, which panics (in the bug). + +package q + +func f() { + var s1 string + var b bool + if b { + b = !b + s1 += "a" + } + + var s2 string + var i, j int + if (s1 <= "") || (s2 >= "") { + j = len(s1[:6]) + } else { + i = len("b") + } + + for j < 0 { + j += i + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26094.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26094.go new file mode 100644 index 0000000000000000000000000000000000000000..7af8fac6b39a6fdb4b544650f0d8e10d5e08e975 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26094.go @@ -0,0 +1,49 @@ +// run + +// Copyright 2018 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 + +import "strings" + +var X interface{} + +type T struct{} + +func scopes() { + p, ok := recover().(error) + if ok && strings.Contains(p.Error(), "different scopes") { + return + } + panic(p) +} + +func F1() { + type T struct{} + X = T{} +} + +func F2() { + type T struct{} + defer scopes() + _ = X.(T) +} + +func F3() { + defer scopes() + _ = X.(T) +} + +func F4() { + X = T{} +} + +func main() { + F1() // set X to F1's T + F2() // check that X is not F2's T + F3() // check that X is not package T + F4() // set X to package T + F2() // check that X is not F2's T +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26097.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26097.go new file mode 100644 index 0000000000000000000000000000000000000000..eedd6bacd0449824031f046a012a651ce5c71f18 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26097.go @@ -0,0 +1,47 @@ +// run + +// Copyright 2018 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 + +//go:noinline +func cmovClobberAX64(v1, v2 int64, x1, x2 float64) int64 { + r := v1 + if x1 == x2 { + r = v2 + } + return r +} + +//go:noinline +func cmovClobberAX32(v1, v2 int32, x1, x2 float64) int32 { + r := v1 + if x1 == x2 { + r = v2 + } + return r +} + +//go:noinline +func cmovClobberAX16(v1, v2 int16, x1, x2 float64) int16 { + r := v1 + if x1 == x2 { + r = v2 + } + return r +} + +func main() { + if cmovClobberAX16(1, 2, 4.0, 5.0) != 1 { + panic("CMOVQEQF causes incorrect code") + } + if cmovClobberAX32(1, 2, 4.0, 5.0) != 1 { + panic("CMOVQEQF causes incorrect code") + } + if cmovClobberAX64(1, 2, 4.0, 5.0) != 1 { + panic("CMOVQEQF causes incorrect code") + } + +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26105.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26105.go new file mode 100644 index 0000000000000000000000000000000000000000..88a5f162f33cd2c6e8da92e5f182bb62bb01f742 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26105.go @@ -0,0 +1,25 @@ +// compile + +// Copyright 2018 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. + +// Triggers a bug in writebarrier, which inserts one +// between (first block) OpAddr x and (second block) a VarDef x, +// which are then in the wrong order and unable to be +// properly scheduled. + +package q + +var S interface{} + +func F(n int) { + fun := func(x int) int { + S = 1 + return n + } + i := fun(([]int{})[n]) + + var fc [2]chan int + S = (([1][2]chan int{fc})[i][i]) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26116.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26116.go new file mode 100644 index 0000000000000000000000000000000000000000..8a6348181c710a2772bce98b748d3d62a068d558 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26116.go @@ -0,0 +1,18 @@ +// run + +// Copyright 2018 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 main() { + s := []int{0, 1, 2} + i := 1 + for i > 0 && s[i] != 2 { + i++ + } + if i != 2 { + panic("loop didn't run") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26120.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26120.go new file mode 100644 index 0000000000000000000000000000000000000000..94bf7d9cb784be0b16c95fef2e8b1d8a806244bd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26120.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2018 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. + +// Issue 26120: INDEX of 1-element but non-SSAable array +// is mishandled when building SSA. + +package p + +type T [1]struct { + f []int + i, j int +} + +func F() { + var v T + f := func() T { + return v + } + _ = []int{}[f()[0].i] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue2615.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue2615.go new file mode 100644 index 0000000000000000000000000000000000000000..831110e08b1e02cdb92c591aa4ce1f39b16c72d3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue2615.go @@ -0,0 +1,547 @@ +// run + +// Copyright 2012 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. + +// Issue 2615: a long chain of else if's causes an overflow +// in the parser stack. + +package main + +// test returns the index of the lowest set bit in a 256-bit vector. +func test(x [4]uint64) int { + if x[0]&(1<<0) != 0 { + return 0 + } else if x[0]&(1<<1) != 0 { + return 1 + } else if x[0]&(1<<2) != 0 { + return 2 + } else if x[0]&(1<<3) != 0 { + return 3 + } else if x[0]&(1<<4) != 0 { + return 4 + } else if x[0]&(1<<5) != 0 { + return 5 + } else if x[0]&(1<<6) != 0 { + return 6 + } else if x[0]&(1<<7) != 0 { + return 7 + } else if x[0]&(1<<8) != 0 { + return 8 + } else if x[0]&(1<<9) != 0 { + return 9 + } else if x[0]&(1<<10) != 0 { + return 10 + } else if x[0]&(1<<11) != 0 { + return 11 + } else if x[0]&(1<<12) != 0 { + return 12 + } else if x[0]&(1<<13) != 0 { + return 13 + } else if x[0]&(1<<14) != 0 { + return 14 + } else if x[0]&(1<<15) != 0 { + return 15 + } else if x[0]&(1<<16) != 0 { + return 16 + } else if x[0]&(1<<17) != 0 { + return 17 + } else if x[0]&(1<<18) != 0 { + return 18 + } else if x[0]&(1<<19) != 0 { + return 19 + } else if x[0]&(1<<20) != 0 { + return 20 + } else if x[0]&(1<<21) != 0 { + return 21 + } else if x[0]&(1<<22) != 0 { + return 22 + } else if x[0]&(1<<23) != 0 { + return 23 + } else if x[0]&(1<<24) != 0 { + return 24 + } else if x[0]&(1<<25) != 0 { + return 25 + } else if x[0]&(1<<26) != 0 { + return 26 + } else if x[0]&(1<<27) != 0 { + return 27 + } else if x[0]&(1<<28) != 0 { + return 28 + } else if x[0]&(1<<29) != 0 { + return 29 + } else if x[0]&(1<<30) != 0 { + return 30 + } else if x[0]&(1<<31) != 0 { + return 31 + } else if x[0]&(1<<32) != 0 { + return 32 + } else if x[0]&(1<<33) != 0 { + return 33 + } else if x[0]&(1<<34) != 0 { + return 34 + } else if x[0]&(1<<35) != 0 { + return 35 + } else if x[0]&(1<<36) != 0 { + return 36 + } else if x[0]&(1<<37) != 0 { + return 37 + } else if x[0]&(1<<38) != 0 { + return 38 + } else if x[0]&(1<<39) != 0 { + return 39 + } else if x[0]&(1<<40) != 0 { + return 40 + } else if x[0]&(1<<41) != 0 { + return 41 + } else if x[0]&(1<<42) != 0 { + return 42 + } else if x[0]&(1<<43) != 0 { + return 43 + } else if x[0]&(1<<44) != 0 { + return 44 + } else if x[0]&(1<<45) != 0 { + return 45 + } else if x[0]&(1<<46) != 0 { + return 46 + } else if x[0]&(1<<47) != 0 { + return 47 + } else if x[0]&(1<<48) != 0 { + return 48 + } else if x[0]&(1<<49) != 0 { + return 49 + } else if x[0]&(1<<50) != 0 { + return 50 + } else if x[0]&(1<<51) != 0 { + return 51 + } else if x[0]&(1<<52) != 0 { + return 52 + } else if x[0]&(1<<53) != 0 { + return 53 + } else if x[0]&(1<<54) != 0 { + return 54 + } else if x[0]&(1<<55) != 0 { + return 55 + } else if x[0]&(1<<56) != 0 { + return 56 + } else if x[0]&(1<<57) != 0 { + return 57 + } else if x[0]&(1<<58) != 0 { + return 58 + } else if x[0]&(1<<59) != 0 { + return 59 + } else if x[0]&(1<<60) != 0 { + return 60 + } else if x[0]&(1<<61) != 0 { + return 61 + } else if x[0]&(1<<62) != 0 { + return 62 + } else if x[0]&(1<<63) != 0 { + return 63 + } else if x[1]&(1<<0) != 0 { + return 64 + } else if x[1]&(1<<1) != 0 { + return 65 + } else if x[1]&(1<<2) != 0 { + return 66 + } else if x[1]&(1<<3) != 0 { + return 67 + } else if x[1]&(1<<4) != 0 { + return 68 + } else if x[1]&(1<<5) != 0 { + return 69 + } else if x[1]&(1<<6) != 0 { + return 70 + } else if x[1]&(1<<7) != 0 { + return 71 + } else if x[1]&(1<<8) != 0 { + return 72 + } else if x[1]&(1<<9) != 0 { + return 73 + } else if x[1]&(1<<10) != 0 { + return 74 + } else if x[1]&(1<<11) != 0 { + return 75 + } else if x[1]&(1<<12) != 0 { + return 76 + } else if x[1]&(1<<13) != 0 { + return 77 + } else if x[1]&(1<<14) != 0 { + return 78 + } else if x[1]&(1<<15) != 0 { + return 79 + } else if x[1]&(1<<16) != 0 { + return 80 + } else if x[1]&(1<<17) != 0 { + return 81 + } else if x[1]&(1<<18) != 0 { + return 82 + } else if x[1]&(1<<19) != 0 { + return 83 + } else if x[1]&(1<<20) != 0 { + return 84 + } else if x[1]&(1<<21) != 0 { + return 85 + } else if x[1]&(1<<22) != 0 { + return 86 + } else if x[1]&(1<<23) != 0 { + return 87 + } else if x[1]&(1<<24) != 0 { + return 88 + } else if x[1]&(1<<25) != 0 { + return 89 + } else if x[1]&(1<<26) != 0 { + return 90 + } else if x[1]&(1<<27) != 0 { + return 91 + } else if x[1]&(1<<28) != 0 { + return 92 + } else if x[1]&(1<<29) != 0 { + return 93 + } else if x[1]&(1<<30) != 0 { + return 94 + } else if x[1]&(1<<31) != 0 { + return 95 + } else if x[1]&(1<<32) != 0 { + return 96 + } else if x[1]&(1<<33) != 0 { + return 97 + } else if x[1]&(1<<34) != 0 { + return 98 + } else if x[1]&(1<<35) != 0 { + return 99 + } else if x[1]&(1<<36) != 0 { + return 100 + } else if x[1]&(1<<37) != 0 { + return 101 + } else if x[1]&(1<<38) != 0 { + return 102 + } else if x[1]&(1<<39) != 0 { + return 103 + } else if x[1]&(1<<40) != 0 { + return 104 + } else if x[1]&(1<<41) != 0 { + return 105 + } else if x[1]&(1<<42) != 0 { + return 106 + } else if x[1]&(1<<43) != 0 { + return 107 + } else if x[1]&(1<<44) != 0 { + return 108 + } else if x[1]&(1<<45) != 0 { + return 109 + } else if x[1]&(1<<46) != 0 { + return 110 + } else if x[1]&(1<<47) != 0 { + return 111 + } else if x[1]&(1<<48) != 0 { + return 112 + } else if x[1]&(1<<49) != 0 { + return 113 + } else if x[1]&(1<<50) != 0 { + return 114 + } else if x[1]&(1<<51) != 0 { + return 115 + } else if x[1]&(1<<52) != 0 { + return 116 + } else if x[1]&(1<<53) != 0 { + return 117 + } else if x[1]&(1<<54) != 0 { + return 118 + } else if x[1]&(1<<55) != 0 { + return 119 + } else if x[1]&(1<<56) != 0 { + return 120 + } else if x[1]&(1<<57) != 0 { + return 121 + } else if x[1]&(1<<58) != 0 { + return 122 + } else if x[1]&(1<<59) != 0 { + return 123 + } else if x[1]&(1<<60) != 0 { + return 124 + } else if x[1]&(1<<61) != 0 { + return 125 + } else if x[1]&(1<<62) != 0 { + return 126 + } else if x[1]&(1<<63) != 0 { + return 127 + } else if x[2]&(1<<0) != 0 { + return 128 + } else if x[2]&(1<<1) != 0 { + return 129 + } else if x[2]&(1<<2) != 0 { + return 130 + } else if x[2]&(1<<3) != 0 { + return 131 + } else if x[2]&(1<<4) != 0 { + return 132 + } else if x[2]&(1<<5) != 0 { + return 133 + } else if x[2]&(1<<6) != 0 { + return 134 + } else if x[2]&(1<<7) != 0 { + return 135 + } else if x[2]&(1<<8) != 0 { + return 136 + } else if x[2]&(1<<9) != 0 { + return 137 + } else if x[2]&(1<<10) != 0 { + return 138 + } else if x[2]&(1<<11) != 0 { + return 139 + } else if x[2]&(1<<12) != 0 { + return 140 + } else if x[2]&(1<<13) != 0 { + return 141 + } else if x[2]&(1<<14) != 0 { + return 142 + } else if x[2]&(1<<15) != 0 { + return 143 + } else if x[2]&(1<<16) != 0 { + return 144 + } else if x[2]&(1<<17) != 0 { + return 145 + } else if x[2]&(1<<18) != 0 { + return 146 + } else if x[2]&(1<<19) != 0 { + return 147 + } else if x[2]&(1<<20) != 0 { + return 148 + } else if x[2]&(1<<21) != 0 { + return 149 + } else if x[2]&(1<<22) != 0 { + return 150 + } else if x[2]&(1<<23) != 0 { + return 151 + } else if x[2]&(1<<24) != 0 { + return 152 + } else if x[2]&(1<<25) != 0 { + return 153 + } else if x[2]&(1<<26) != 0 { + return 154 + } else if x[2]&(1<<27) != 0 { + return 155 + } else if x[2]&(1<<28) != 0 { + return 156 + } else if x[2]&(1<<29) != 0 { + return 157 + } else if x[2]&(1<<30) != 0 { + return 158 + } else if x[2]&(1<<31) != 0 { + return 159 + } else if x[2]&(1<<32) != 0 { + return 160 + } else if x[2]&(1<<33) != 0 { + return 161 + } else if x[2]&(1<<34) != 0 { + return 162 + } else if x[2]&(1<<35) != 0 { + return 163 + } else if x[2]&(1<<36) != 0 { + return 164 + } else if x[2]&(1<<37) != 0 { + return 165 + } else if x[2]&(1<<38) != 0 { + return 166 + } else if x[2]&(1<<39) != 0 { + return 167 + } else if x[2]&(1<<40) != 0 { + return 168 + } else if x[2]&(1<<41) != 0 { + return 169 + } else if x[2]&(1<<42) != 0 { + return 170 + } else if x[2]&(1<<43) != 0 { + return 171 + } else if x[2]&(1<<44) != 0 { + return 172 + } else if x[2]&(1<<45) != 0 { + return 173 + } else if x[2]&(1<<46) != 0 { + return 174 + } else if x[2]&(1<<47) != 0 { + return 175 + } else if x[2]&(1<<48) != 0 { + return 176 + } else if x[2]&(1<<49) != 0 { + return 177 + } else if x[2]&(1<<50) != 0 { + return 178 + } else if x[2]&(1<<51) != 0 { + return 179 + } else if x[2]&(1<<52) != 0 { + return 180 + } else if x[2]&(1<<53) != 0 { + return 181 + } else if x[2]&(1<<54) != 0 { + return 182 + } else if x[2]&(1<<55) != 0 { + return 183 + } else if x[2]&(1<<56) != 0 { + return 184 + } else if x[2]&(1<<57) != 0 { + return 185 + } else if x[2]&(1<<58) != 0 { + return 186 + } else if x[2]&(1<<59) != 0 { + return 187 + } else if x[2]&(1<<60) != 0 { + return 188 + } else if x[2]&(1<<61) != 0 { + return 189 + } else if x[2]&(1<<62) != 0 { + return 190 + } else if x[2]&(1<<63) != 0 { + return 191 + } else if x[3]&(1<<0) != 0 { + return 192 + } else if x[3]&(1<<1) != 0 { + return 193 + } else if x[3]&(1<<2) != 0 { + return 194 + } else if x[3]&(1<<3) != 0 { + return 195 + } else if x[3]&(1<<4) != 0 { + return 196 + } else if x[3]&(1<<5) != 0 { + return 197 + } else if x[3]&(1<<6) != 0 { + return 198 + } else if x[3]&(1<<7) != 0 { + return 199 + } else if x[3]&(1<<8) != 0 { + return 200 + } else if x[3]&(1<<9) != 0 { + return 201 + } else if x[3]&(1<<10) != 0 { + return 202 + } else if x[3]&(1<<11) != 0 { + return 203 + } else if x[3]&(1<<12) != 0 { + return 204 + } else if x[3]&(1<<13) != 0 { + return 205 + } else if x[3]&(1<<14) != 0 { + return 206 + } else if x[3]&(1<<15) != 0 { + return 207 + } else if x[3]&(1<<16) != 0 { + return 208 + } else if x[3]&(1<<17) != 0 { + return 209 + } else if x[3]&(1<<18) != 0 { + return 210 + } else if x[3]&(1<<19) != 0 { + return 211 + } else if x[3]&(1<<20) != 0 { + return 212 + } else if x[3]&(1<<21) != 0 { + return 213 + } else if x[3]&(1<<22) != 0 { + return 214 + } else if x[3]&(1<<23) != 0 { + return 215 + } else if x[3]&(1<<24) != 0 { + return 216 + } else if x[3]&(1<<25) != 0 { + return 217 + } else if x[3]&(1<<26) != 0 { + return 218 + } else if x[3]&(1<<27) != 0 { + return 219 + } else if x[3]&(1<<28) != 0 { + return 220 + } else if x[3]&(1<<29) != 0 { + return 221 + } else if x[3]&(1<<30) != 0 { + return 222 + } else if x[3]&(1<<31) != 0 { + return 223 + } else if x[3]&(1<<32) != 0 { + return 224 + } else if x[3]&(1<<33) != 0 { + return 225 + } else if x[3]&(1<<34) != 0 { + return 226 + } else if x[3]&(1<<35) != 0 { + return 227 + } else if x[3]&(1<<36) != 0 { + return 228 + } else if x[3]&(1<<37) != 0 { + return 229 + } else if x[3]&(1<<38) != 0 { + return 230 + } else if x[3]&(1<<39) != 0 { + return 231 + } else if x[3]&(1<<40) != 0 { + return 232 + } else if x[3]&(1<<41) != 0 { + return 233 + } else if x[3]&(1<<42) != 0 { + return 234 + } else if x[3]&(1<<43) != 0 { + return 235 + } else if x[3]&(1<<44) != 0 { + return 236 + } else if x[3]&(1<<45) != 0 { + return 237 + } else if x[3]&(1<<46) != 0 { + return 238 + } else if x[3]&(1<<47) != 0 { + return 239 + } else if x[3]&(1<<48) != 0 { + return 240 + } else if x[3]&(1<<49) != 0 { + return 241 + } else if x[3]&(1<<50) != 0 { + return 242 + } else if x[3]&(1<<51) != 0 { + return 243 + } else if x[3]&(1<<52) != 0 { + return 244 + } else if x[3]&(1<<53) != 0 { + return 245 + } else if x[3]&(1<<54) != 0 { + return 246 + } else if x[3]&(1<<55) != 0 { + return 247 + } else if x[3]&(1<<56) != 0 { + return 248 + } else if x[3]&(1<<57) != 0 { + return 249 + } else if x[3]&(1<<58) != 0 { + return 250 + } else if x[3]&(1<<59) != 0 { + return 251 + } else if x[3]&(1<<60) != 0 { + return 252 + } else if x[3]&(1<<61) != 0 { + return 253 + } else if x[3]&(1<<62) != 0 { + return 254 + } else if x[3]&(1<<63) != 0 { + return 255 + } + return -1 +} + +func main() { + const ones = ^uint64(0) + for i := 0; i < 256; i++ { + bits := [4]uint64{ones, ones, ones, ones} + + // clear bottom i bits + bits[i/64] ^= 1<<(uint(i)&63) - 1 + for j := i/64 - 1; j >= 0; j-- { + bits[j] = 0 + } + + k := test(bits) + if k != i { + print("test(bits)=", k, " want ", i, "\n") + panic("failed") + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26153.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26153.go new file mode 100644 index 0000000000000000000000000000000000000000..53f53cf8a66fd49de17682e792f2783705fea2be --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26153.go @@ -0,0 +1,29 @@ +// run + +// Copyright 2018 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. + +// Issue 26153. The write to ps was incorrectly +// removed by the dead auto elimination pass. + +package main + +const hello = "hello world" + +func main() { + var s string + mangle(&s) + if s != hello { + panic("write incorrectly elided") + } +} + +//go:noinline +func mangle(ps *string) { + if ps == nil { + var s string + ps = &s + } + *ps = hello +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26163.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26163.go new file mode 100644 index 0000000000000000000000000000000000000000..3f3d77859def812a43f934347592b7013c87836e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26163.go @@ -0,0 +1,17 @@ +// compile -N -d=softfloat + +// Copyright 2018 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. + +// Issue 26163: dead store generated in late opt messes +// up store chain calculation. + +package p + +var i int +var A = ([]*int{})[i] + +var F func(float64, complex128) int +var C chan complex128 +var B = F(1, 1+(<-C)) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26248.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26248.go new file mode 100644 index 0000000000000000000000000000000000000000..2f04e48224c79448110677efc2580b02b65c80c4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26248.go @@ -0,0 +1,39 @@ +// run + +// Copyright 2018 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. + +// Issue 26248: gccgo miscompiles interface field expression. +// In G().M where G returns an interface, G() is evaluated twice. + +package main + +type I interface { + M() +} + +type T struct{} + +func (T) M() {} + +var g = 0 + +//go:noinline +func G() I { + g++ + return T{} +} + +//go:noinline +func Use(interface{}) {} + +func main() { + x := G().M + Use(x) + + if g != 1 { + println("want 1, got", g) + panic("FAIL") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26335.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26335.go new file mode 100644 index 0000000000000000000000000000000000000000..a97b4b6c72c2c1d6bebee918f39e3f0bd021e58a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26335.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2018 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. + +// gccgo mishandled passing a struct with an empty field through +// reflect.Value.Call. + +package main + +import ( + "reflect" +) + +type Empty struct { + f1, f2 *byte + empty struct{} +} + +func F(e Empty, s []string) { + if len(s) != 1 || s[0] != "hi" { + panic("bad slice") + } +} + +func main() { + reflect.ValueOf(F).Call([]reflect.Value{ + reflect.ValueOf(Empty{}), + reflect.ValueOf([]string{"hi"}), + }) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26340.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26340.go new file mode 100644 index 0000000000000000000000000000000000000000..f973ce2237eb86232ed59f5362c31a2aa99788cf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26340.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2018 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. + +// gccgo did not permit omitting the type of a composite literal +// element when one of the middle omitted types was a pointer type. + +package p + +type S []T +type T struct { x int } + +var _ = map[string]*S{ + "a": { + { 1 }, + }, +} + +var _ = [1]*S{ { {1}, } } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26341.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26341.go new file mode 100644 index 0000000000000000000000000000000000000000..128cf9d06ad6ed5c0d03c3889cf3ea483ad289af --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26341.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2018 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26407.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26407.go new file mode 100644 index 0000000000000000000000000000000000000000..aa8e79c1e6ada0184b3839974614d2187d4e9b74 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26407.go @@ -0,0 +1,58 @@ +// run + +// Copyright 2018 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. + +// Issue 26407: ensure that stack variables which have +// had their address taken and then used in a comparison, +// but are otherwise unused, are cleared. + +package main + +func main() { + poison() + test() +} + +//go:noinline +func poison() { + // initialise the stack with invalid pointers + var large [256]uintptr + for i := range large { + large[i] = 1 + } + use(large[:]) +} + +//go:noinline +func test() { + a := 2 + x := &a + if x != compare(&x) { + panic("not possible") + } +} + +//go:noinline +func compare(x **int) *int { + var y *int + if x == &y { + panic("not possible") + } + // grow the stack to trigger a check for invalid pointers + grow() + if x == &y { + panic("not possible") + } + return *x +} + +//go:noinline +func grow() { + var large [1 << 16]uintptr + use(large[:]) +} + +//go:noinline +func use(_ []uintptr) { } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26411.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26411.go new file mode 100644 index 0000000000000000000000000000000000000000..d7b2a26ff49c17aa88fd384db400d09ece57b377 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26411.go @@ -0,0 +1,93 @@ +// run + +//go:build !nacl && !js && !wasip1 + +// Copyright 2018 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. + +// Ensure that label redefinition errors print out +// a column number that matches the start of the current label's +// definition instead of the label delimiting token ":" + +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "log" + "os" + "os/exec" + "path/filepath" + "regexp" +) + +func main() { + tmpdir, err := ioutil.TempDir("", "issue26411") + if err != nil { + log.Fatalf("Failed to create temporary directory: %v", err) + } + defer os.RemoveAll(tmpdir) + + tests := []struct { + code string + errors []string + }{ + { + code: ` +package main + +func main() { +foo: +foo: +} +`, + errors: []string{ + "^.+:5:1: label foo defined and not used\n", + ".+:6:1: label foo already defined at .+:5:1\n$", + }, + }, + { + code: ` +package main + +func main() { + + bar: + bar: +bar: +bar : +} +`, + + errors: []string{ + "^.+:6:13: label bar defined and not used\n", + ".+:7:4: label bar already defined at .+:6:13\n", + ".+:8:1: label bar already defined at .+:6:13\n", + ".+:9:1: label bar already defined at .+:6:13\n$", + }, + }, + } + + for i, test := range tests { + filename := filepath.Join(tmpdir, fmt.Sprintf("%d.go", i)) + if err := ioutil.WriteFile(filename, []byte(test.code), 0644); err != nil { + log.Printf("#%d: failed to create file %s", i, filename) + continue + } + output, _ := exec.Command("go", "tool", "compile", "-p=p", filename).CombinedOutput() + + // remove each matching error from the output + for _, err := range test.errors { + rx := regexp.MustCompile(err) + match := rx.Find(output) + output = bytes.Replace(output, match, nil, 1) // remove match (which might be nil) from output + } + + // at this point all output should have been consumed + if len(output) != 0 { + log.Printf("Test case %d has unmatched errors:\n%s", i, output) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26416.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26416.go new file mode 100644 index 0000000000000000000000000000000000000000..44a4fc73b777f152f4b1371e456b0527af8efe70 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26416.go @@ -0,0 +1,27 @@ +// errorcheck + +// Copyright 2018 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 + +type t1 struct { + t1f1 int + t1f2 int +} +type t2 struct { + t2f1 int + t2f2 int + *t1 +} +type t3 struct { + t3f1 int + *t2 +} + +var ( + _ = t2{t1f1: 600} // ERROR "cannot use promoted field t1.t1f1 in struct literal of type t2|unknown field" + _ = t3{t1f2: 800} // ERROR "cannot use promoted field t2.t1.t1f2 in struct literal of type t3|unknown field" + _ = t3{t2f1: 900} // ERROR "cannot use promoted field t2.t2f1 in struct literal of type t3|unknown field" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26426.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26426.go new file mode 100644 index 0000000000000000000000000000000000000000..4f2a452faa7c2ff85f607e8b60841746dbb6286c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26426.go @@ -0,0 +1,29 @@ +//run + +// Copyright 2018 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 + +//go:noinline +func f(p *int, v int, q1, q2 *int, r *bool) { + x := *r + if x { + *q1 = 1 + } + *p = *p + v // This must clobber flags. Otherwise we keep x in a flags register. + if x { + *q2 = 1 + } +} + +func main() { + var p int + var q1, q2 int + var b bool + f(&p, 1, &q1, &q2, &b) + if q1 != 0 || q2 != 0 { + panic("bad") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26438.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26438.go new file mode 100644 index 0000000000000000000000000000000000000000..d44da21eb07cbaa7412e28489cd1be907e2a2e08 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26438.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2018 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. + +// Issue 26438: arm64 backend may use 64-bit TST for +// "if uint32(a)&uint32(b) == 0", which should be +// 32-bit TSTW + +package main + +//go:noinline +func tstw(a, b uint64) uint64 { + if uint32(a)&uint32(b) == 0 { + return 100 + } else { + return 200 + } +} + +func main() { + if tstw(0xff00000000, 0xaa00000000) == 200 { + panic("impossible") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26495.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26495.go new file mode 100644 index 0000000000000000000000000000000000000000..11ea360173f6c44398a6a0b554627d5c71980ae9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26495.go @@ -0,0 +1,36 @@ +// run + +// Copyright 2018 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. + +// Issue 26495: gccgo produces incorrect order of evaluation +// for expressions involving &&, || subexpressions. + +package main + +var i int + +func checkorder(order int) { + if i != order { + panic("FAIL: wrong evaluation order") + } + i++ +} + +func A() bool { checkorder(1); return true } +func B() bool { checkorder(2); return true } +func C() bool { checkorder(5); return false } +func D() bool { panic("FAIL: D should not be called") } +func E() int { checkorder(3); return 0 } +func F() int { checkorder(0); return 0 } +func G(bool) int { checkorder(9); return 0 } +func H(int, bool, int) int { checkorder(7); return 0 } +func I(int) bool { checkorder(8); return true } +func J() int { checkorder(4); return 0 } +func K() int { checkorder(6); return 0 } +func L() int { checkorder(10); return 0 } + +func main() { + _ = F() + G(A() && B() && I(E()+H(J(), C() && D(), K()))) + L() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26616.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26616.go new file mode 100644 index 0000000000000000000000000000000000000000..edf88d489ecc666b93e5bc8c1fc40d5140b1de71 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26616.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2018 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 p + +var x int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context|multiple-value " + +func f() { + var _ int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context|multiple-value " + var a int = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context|multiple-value " + a = three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|multiple-value function call in single-value context|cannot assign" + b := three() // ERROR "assignment mismatch: 1 variable but three returns 3 values|single variable set to multiple-value|multiple-value function call in single-value context|cannot initialize" + _, _ = a, b +} + +func three() (int, int, int) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue26855.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue26855.go new file mode 100644 index 0000000000000000000000000000000000000000..b965635a65ce3ad9c585fe54aa9d02ba185f8aaa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue26855.go @@ -0,0 +1,28 @@ +// errorcheck + +// Copyright 2012 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. + +// Verify that we get the correct (T vs &T) literal specification +// in the error message. + +package p + +type S struct { + f T +} + +type P struct { + f *T +} + +type T struct{} + +var _ = S{ + f: &T{}, // ERROR "cannot use &T{}|incompatible type" +} + +var _ = P{ + f: T{}, // ERROR "cannot use T{}|incompatible type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27143.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27143.go new file mode 100644 index 0000000000000000000000000000000000000000..009ec9f6c255efd23cb5b9ff6f18a6f454e71cba --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27143.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2018 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. + +// Issue 27143: cmd/compile: erroneous application of walkinrange +// optimization for const over 2**63 + +package p + +var c uint64 + +var b1 bool = 0x7fffffffffffffff < c && c < 0x8000000000000000 +var b2 bool = c < 0x8000000000000000 && 0x7fffffffffffffff < c +var b3 bool = 0x8000000000000000 < c && c < 0x8000000000000001 +var b4 bool = c < 0x8000000000000001 && 0x8000000000000000 < c diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27201.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27201.go new file mode 100644 index 0000000000000000000000000000000000000000..0c9611fc73b93db3d2da92ffb68bd468d317db47 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27201.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2019 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 + +import ( + "runtime" + "strings" +) + +func main() { + f(nil) +} + +func f(p *int32) { + defer checkstack() + v := *p // panic should happen here, line 20 + sink = int64(v) // not here, line 21 +} + +var sink int64 + +func checkstack() { + _ = recover() + var buf [1024]byte + n := runtime.Stack(buf[:], false) + s := string(buf[:n]) + if strings.Contains(s, "issue27201.go:21 ") { + panic("panic at wrong location") + } + if !strings.Contains(s, "issue27201.go:20 ") { + panic("no panic at correct location") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27232.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27232.go new file mode 100644 index 0000000000000000000000000000000000000000..3a1cc87e4cb964ad0e3cf3dd5a490ef371f2b713 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27232.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2018 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 p + +type F = func(T) + +type T interface { + m(F) +} + +type t struct{} + +func (t) m(F) {} + +var _ T = &t{} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27267.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27267.go new file mode 100644 index 0000000000000000000000000000000000000000..ebae44f48fefc89406f178be669b8a07df32c3c9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27267.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2018 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 p + +// 1st test case from issue +type F = func(E) // compiles if not type alias or moved below E struct +type E struct { + f F +} + +var x = E{func(E) {}} + +// 2nd test case from issue +type P = *S +type S struct { + p P +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27278.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27278.go new file mode 100644 index 0000000000000000000000000000000000000000..73f7c755e1e3e422599283a1f3adf217217ac7fd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27278.go @@ -0,0 +1,63 @@ +// run + +// Copyright 2018 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. + +// Issue 27278: dead auto elim deletes an auto and its +// initialization, but it is live because of a nil check. + +package main + +type T struct { + _ [3]string + T2 +} + +func (t *T) M() []string { + return t.T2.M() +} + +type T2 struct { + T3 +} + +func (t *T2) M() []string { + return t.T3.M() +} + +type T3 struct { + a string +} + +func (t *T3) M() []string { + return []string{} +} + +func main() { + poison() + f() +} + +//go:noinline +func f() { + (&T{}).M() + grow(10000) +} + +// grow stack, triggers stack copy +func grow(n int) { + if n == 0 { + return + } + grow(n-1) +} + +// put some junk on stack, which cannot be valid address +//go:noinline +func poison() { + x := [10]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10} + g = x +} + +var g [10]int diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27289.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27289.go new file mode 100644 index 0000000000000000000000000000000000000000..293b9d005570f8b3fad054759d6337fda8f35bb6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27289.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2018 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. + +// Make sure we don't prove that the bounds check failure branch is unreachable. + +package main + +//go:noinline +func f(a []int) { + _ = a[len(a)-1] +} + +func main() { + defer func() { + if err := recover(); err != nil { + return + } + panic("f should panic") + }() + f(nil) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27356.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27356.go new file mode 100644 index 0000000000000000000000000000000000000000..c3e686df339544ff8f7b6954a35420a5ca310120 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27356.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2018 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. + +// Issue 27356: function parameter hiding built-in function results in compiler crash + +package p + +var a = []int{1,2,3} + +func _(len int) { + _ = len(a) // ERROR "cannot call non-function|expected function" +} + +var cap = false +var _ = cap(a) // ERROR "cannot call non-function|expected function" + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27518a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27518a.go new file mode 100644 index 0000000000000000000000000000000000000000..d6224df017dc4b170ed775d6e8f3deb21dd84435 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27518a.go @@ -0,0 +1,45 @@ +// run + +// Copyright 2018 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 + +import ( + "runtime" +) + +var nilp *int +var forceHeap interface{} + +func main() { + // x is a pointer on the stack to heap-allocated memory. + x := new([32]*int) + forceHeap = x + forceHeap = nil + + // Push a defer to be run when we panic below. + defer func() { + // Ignore the panic. + recover() + // Force a stack walk. Go 1.11 will fail because x is now + // considered live again. + runtime.GC() + }() + // Make x live at the defer's PC. + runtime.KeepAlive(x) + + // x is no longer live. Garbage collect the [32]*int on the + // heap. + runtime.GC() + // At this point x's dead stack slot points to dead memory. + + // Trigger a sigpanic. Since this is an implicit panic, we + // don't have an explicit liveness map here. + // Traceback used to use the liveness map of the most recent defer, + // but in that liveness map, x will be live again even though + // it points to dead memory. The fix is to use the liveness + // map of a deferreturn call instead. + *nilp = 0 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27518b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27518b.go new file mode 100644 index 0000000000000000000000000000000000000000..ea72a3088503b56bb71973c1bbf002f9b75bc554 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27518b.go @@ -0,0 +1,72 @@ +// run + +// Copyright 2018 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 + +import "runtime" + +var finalized bool +var err string + +type HeapObj [8]int64 + +const filler int64 = 0x123456789abcdef0 + +func (h *HeapObj) init() { + for i := 0; i < len(*h); i++ { + h[i] = filler + } +} +func (h *HeapObj) check() { + for i := 0; i < len(*h); i++ { + if h[i] != filler { + err = "filler overwritten" + } + } +} + +type StackObj struct { + h *HeapObj +} + +func gc(shouldFinalize bool) { + runtime.GC() + runtime.GC() + runtime.GC() + if shouldFinalize != finalized { + err = "heap object finalized at the wrong time" + } +} + +func main() { + var s StackObj + s.h = new(HeapObj) + s.h.init() + runtime.SetFinalizer(s.h, func(h *HeapObj) { + finalized = true + }) + gc(false) + h := g(&s) + gc(false) + h.check() + gc(true) // finalize here, after return value's last use. (Go1.11 never runs the finalizer.) + if err != "" { + panic(err) + } +} + +func g(p *StackObj) (v *HeapObj) { + gc(false) + v = p.h // last use of the stack object. the only reference to the heap object is in the return slot. + gc(false) + defer func() { + gc(false) + recover() + gc(false) + }() + *(*int)(nil) = 0 + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27557.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27557.go new file mode 100644 index 0000000000000000000000000000000000000000..f609b27faa5e12ddc4e03218c36e5916d4c43271 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27557.go @@ -0,0 +1,41 @@ +// errorcheck -0 -l -m + +// Copyright 2019 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 p + +var sink interface{} + +func f1() { + var t T + f := t.noescape // ERROR "t.noescape does not escape" + f() +} + +func f2() { + var t T // ERROR "moved to heap" + f := t.escape // ERROR "t.escape does not escape" + f() +} + +func f3() { + var t T // ERROR "moved to heap" + f := t.returns // ERROR "t.returns does not escape" + sink = f() +} + +type T struct{} + +func (t *T) noescape() {} // ERROR "t does not escape" +func (t *T) escape() { sink = t } // ERROR "leaking param: t$" +func (t *T) returns() *T { return t } // ERROR "leaking param: t to result ~r0 level=0" + +func (t *T) recursive() { // ERROR "leaking param: t$" + sink = t + + var t2 T // ERROR "moved to heap" + f := t2.recursive // ERROR "t2.recursive does not escape" + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27595.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27595.go new file mode 100644 index 0000000000000000000000000000000000000000..86fb6384cdb5b48c99028db2e5fd1b60703b0ca8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27595.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2018 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 + +var a = twoResults() // ERROR "assignment mismatch: 1 variable but twoResults returns 2 values|multiple-value twoResults\(\) .*in single-value context" +var b, c, d = twoResults() // ERROR "assignment mismatch: 3 variables but twoResults returns 2 values|cannot initialize" +var e, f = oneResult() // ERROR "assignment mismatch: 2 variables but oneResult returns 1 value|cannot initialize" + +func twoResults() (int, int) { + return 1, 2 +} + +func oneResult() int { + return 1 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27695.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27695.go new file mode 100644 index 0000000000000000000000000000000000000000..8bd4939e7ecb4b0862f9b575ee804aaba94d0c25 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27695.go @@ -0,0 +1,62 @@ +// run + +// Copyright 2018 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. + +// Make sure return values are always scanned, when +// calling methods (+functions, TODO) with reflect. + +package main + +import ( + "reflect" + "runtime/debug" + "sync" +) + +func main() { + debug.SetGCPercent(1) // run GC frequently + var wg sync.WaitGroup + for i := 0; i < 20; i++ { + wg.Add(1) + go func() { + defer wg.Done() + for i := 0; i < 2000; i++ { + _test() + } + }() + } + wg.Wait() +} + +type Stt struct { + Data interface{} +} + +type My struct { + b byte +} + +func (this *My) Run(rawData []byte) (Stt, error) { + var data string = "hello" + stt := Stt{ + Data: data, + } + return stt, nil +} + +func _test() (interface{}, error) { + f := reflect.ValueOf(&My{}).MethodByName("Run") + if method, ok := f.Interface().(func([]byte) (Stt, error)); ok { + s, e := method(nil) + // The bug in issue27695 happens here, during the return + // from the above call (at the end of reflect.callMethod + // when preparing to return). The result value that + // is assigned to s was not being scanned if GC happens + // to occur there. + i := interface{}(s) + return i, e + } + return nil, nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27695b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27695b.go new file mode 100644 index 0000000000000000000000000000000000000000..d80acfb8b40eef0d7114083610f998af910cbd3d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27695b.go @@ -0,0 +1,64 @@ +// run + +// Copyright 2018 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. + +// Make sure return values aren't scanned until they +// are initialized, when calling functions and methods +// via reflect. + +package main + +import ( + "reflect" + "runtime" + "unsafe" +) + +var badPtr uintptr + +var sink []byte + +func init() { + // Allocate large enough to use largeAlloc. + b := make([]byte, 1<<16-1) + sink = b // force heap allocation + // Any space between the object and the end of page is invalid to point to. + badPtr = uintptr(unsafe.Pointer(&b[len(b)-1])) + 1 +} + +func f(d func() *byte) *byte { + // Initialize callee args section with a bad pointer. + g(badPtr) + + // Then call a function which returns a pointer. + // That return slot starts out holding a bad pointer. + return d() +} + +//go:noinline +func g(x uintptr) { +} + +type T struct { +} + +func (t *T) Foo() *byte { + runtime.GC() + return nil +} + +func main() { + // Functions + d := reflect.MakeFunc(reflect.TypeOf(func() *byte { return nil }), + func(args []reflect.Value) []reflect.Value { + runtime.GC() + return []reflect.Value{reflect.ValueOf((*byte)(nil))} + }).Interface().(func() *byte) + f(d) + + // Methods + e := reflect.ValueOf(&T{}).Method(0).Interface().(func() *byte) + f(e) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27695c.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27695c.go new file mode 100644 index 0000000000000000000000000000000000000000..948191cc9668689db2dfd5af3960d406d93d8d18 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27695c.go @@ -0,0 +1,65 @@ +// run + +// Copyright 2018 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. + +// Make sure return values aren't scanned until they +// are initialized, when calling functions and methods +// via reflect. + +package main + +import ( + "io" + "reflect" + "runtime" + "unsafe" +) + +var badPtr uintptr + +var sink []byte + +func init() { + // Allocate large enough to use largeAlloc. + b := make([]byte, 1<<16-1) + sink = b // force heap allocation + // Any space between the object and the end of page is invalid to point to. + badPtr = uintptr(unsafe.Pointer(&b[len(b)-1])) + 1 +} + +func f(d func(error) error) error { + // Initialize callee args section with a bad pointer. + g(badPtr, badPtr, badPtr, badPtr) + + // Then call a function which returns a pointer. + // That return slot starts out holding a bad pointer. + return d(io.EOF) +} + +//go:noinline +func g(x, y, z, w uintptr) { +} + +type T struct { +} + +func (t *T) Foo(e error) error { + runtime.GC() + return e +} + +func main() { + // Functions + d := reflect.MakeFunc(reflect.TypeOf(func(e error) error { return e }), + func(args []reflect.Value) []reflect.Value { + runtime.GC() + return args + }).Interface().(func(error) error) + f(d) + + // Methods + x := reflect.ValueOf(&T{}).Method(0).Interface().(func(error) error) + f(x) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27718.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27718.go new file mode 100644 index 0000000000000000000000000000000000000000..ff616fb0f29043f183c6a0aaeb85ffaa3c8ed3c9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27718.go @@ -0,0 +1,102 @@ +// run + +// Copyright 2018 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. + +// (-0)+0 should be 0, not -0. + +package main + +//go:noinline +func add64(x float64) float64 { + return x + 0 +} + +func testAdd64() { + var zero float64 + inf := 1.0 / zero + negZero := -1 / inf + if 1/add64(negZero) != inf { + panic("negZero+0 != posZero (64 bit)") + } +} + +//go:noinline +func sub64(x float64) float64 { + return x - 0 +} + +func testSub64() { + var zero float64 + inf := 1.0 / zero + negZero := -1 / inf + if 1/sub64(negZero) != -inf { + panic("negZero-0 != negZero (64 bit)") + } +} + +//go:noinline +func neg64(x float64) float64 { + return -x +} + +func testNeg64() { + var zero float64 + inf := 1.0 / zero + negZero := -1 / inf + if 1/neg64(negZero) != inf { + panic("-negZero != posZero (64 bit)") + } +} + +//go:noinline +func add32(x float32) float32 { + return x + 0 +} + +func testAdd32() { + var zero float32 + inf := 1.0 / zero + negZero := -1 / inf + if 1/add32(negZero) != inf { + panic("negZero+0 != posZero (32 bit)") + } +} + +//go:noinline +func sub32(x float32) float32 { + return x - 0 +} + +func testSub32() { + var zero float32 + inf := 1.0 / zero + negZero := -1 / inf + if 1/sub32(negZero) != -inf { + panic("negZero-0 != negZero (32 bit)") + } +} + +//go:noinline +func neg32(x float32) float32 { + return -x +} + +func testNeg32() { + var zero float32 + inf := 1.0 / zero + negZero := -1 / inf + if 1/neg32(negZero) != inf { + panic("-negZero != posZero (32 bit)") + } +} + +func main() { + testAdd64() + testSub64() + testNeg64() + testAdd32() + testSub32() + testNeg32() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27732a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27732a.go new file mode 100644 index 0000000000000000000000000000000000000000..2d0198da0e89773fb816d0d50d60cbeae3e6b79f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27732a.go @@ -0,0 +1,23 @@ +// errorcheck -0 -m -l -smallframes + +// Copyright 2019 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. + +// This checks that the -smallframes flag forces a large variable to heap. + +package main + +const ( + bufferLen = 200000 +) + +type kbyte []byte +type circularBuffer [bufferLen]kbyte + +var sink byte + +func main() { + var c circularBuffer // ERROR "moved to heap: c$" + sink = c[0][0] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27829.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27829.go new file mode 100644 index 0000000000000000000000000000000000000000..920404320285288459046467686bb878c57017e2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27829.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2018 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. + +// Bad AND/BTR combination rule. + +package main + +import "fmt" + +//go:noinline +func f(x uint64) uint64 { + return (x >> 48) &^ (uint64(0x4000)) +} + +func main() { + bad := false + if got, want := f(^uint64(0)), uint64(0xbfff); got != want { + fmt.Printf("got %x, want %x\n", got, want) + bad = true + } + if bad { + panic("bad") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27836.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27836.go new file mode 100644 index 0000000000000000000000000000000000000000..128cf9d06ad6ed5c0d03c3889cf3ea483ad289af --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27836.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2018 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27938.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27938.go new file mode 100644 index 0000000000000000000000000000000000000000..5392c65f1fcf842ef9929314bcba2c2a0bdb0cb3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27938.go @@ -0,0 +1,23 @@ +// errorcheck -d=panic + +// Copyright 2018 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. + +// Verify that we get a single non-confusing error +// message for embedded fields/interfaces that use +// a qualified identifier with non-existing package. + +package p + +type _ struct { + F sync.Mutex // ERROR "undefined: sync|expected package|reference to undefined name" +} + +type _ struct { + sync.Mutex // ERROR "undefined: sync|expected package|reference to undefined name" +} + +type _ interface { + sync.Mutex // ERROR "undefined: sync|expected package|expected signature or type name|reference to undefined name" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue27961.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue27961.go new file mode 100644 index 0000000000000000000000000000000000000000..f8b4f669c482853bfc70f9ed9b7e1756256ce2eb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue27961.go @@ -0,0 +1,35 @@ +// run + +// Copyright 2018 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. + +// Issue 27961: some optimizations generate OffPtr with wrong +// types, which causes invalid bytecode on Wasm. + +package main + +import "math" + +type Vec2 [2]float64 + +func main() { + var a Vec2 + a.A().B().C().D() +} + +func (v Vec2) A() Vec2 { + return Vec2{v[0], v[0]} +} + +func (v Vec2) B() Vec2 { + return Vec2{1.0 / v.D(), 0} +} + +func (v Vec2) C() Vec2 { + return Vec2{v[0], v[0]} +} + +func (v Vec2) D() float64 { + return math.Sqrt(v[0]) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue28055.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue28055.go new file mode 100644 index 0000000000000000000000000000000000000000..d4889d54d4530bf8b4fa017f6960abd9d6e43d8e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue28055.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2018 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. + +// Make sure VARDEF can be a top-level statement. + +package p + +func f() { + var s string + var as []string + switch false && (s+"a"+as[0]+s+as[0]+s == "") { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue28058.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue28058.go new file mode 100644 index 0000000000000000000000000000000000000000..d8206e73576c4e2fa2c03afe332368217082caa3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue28058.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2018 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. + +// Issue 14988: declaring a map with an invalid key type should not cause a +// fatal panic. + +package main + +var x map[func()]int // ERROR "invalid map key type" +var X map[func()]int // ERROR "invalid map key type" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue28078.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue28078.go new file mode 100644 index 0000000000000000000000000000000000000000..2e4c4b55164e7febabdf2fe0f0c7092b7b2aba6f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue28078.go @@ -0,0 +1,34 @@ +// compile + +// Copyright 2018 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. + +// Non-constant duplicate keys/cases should not be reported +// as errors by the compiler. + +package p + +import "unsafe" + +func f() { + _ = map[uintptr]int{ + 0: 0, + uintptr(unsafe.Pointer(nil)): 0, + } + + switch uintptr(0) { + case 0: + case uintptr(unsafe.Pointer(nil)): + } + + switch interface{}(nil) { + case nil: + case nil: + } + + _ = map[interface{}]int{ + nil: 0, + nil: 0, + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue28079a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue28079a.go new file mode 100644 index 0000000000000000000000000000000000000000..b0631bbd86b8eb1fed4a6f0bed33fc402865c51b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue28079a.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2018 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. + +// Non-Go-constant but constant indexes are ok at compile time. + +package p + +import "unsafe" + +func f() { + var x [0]int + x[uintptr(unsafe.Pointer(nil))] = 0 +} +func g() { + var x [10]int + _ = x[3:uintptr(unsafe.Pointer(nil))] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue28079b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue28079b.go new file mode 100644 index 0000000000000000000000000000000000000000..69d1a2f480897d9be894cb26e7395f5552195385 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue28079b.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2018 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. + +// Non-Go-constant but constant values aren't ok for array sizes. + +package p + +import "unsafe" + +type T [uintptr(unsafe.Pointer(nil))]int // ERROR "non-constant array bound|array bound is not constant|must be constant" + +func f() { + _ = complex(1<> 1) + +func main() { + s := make([]T, maxInt) + shouldPanic("len out of range", func() { s = append(s, T{}) }) + var oneElem = make([]T, 1) + shouldPanic("len out of range", func() { s = append(s, oneElem...) }) +} + +func shouldPanic(str string, f func()) { + defer func() { + err := recover() + if err == nil { + panic("did not panic") + } + s := err.(error).Error() + if !strings.Contains(s, str) { + panic("got panic " + s + ", want " + str) + } + }() + + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29215.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29215.go new file mode 100644 index 0000000000000000000000000000000000000000..4e8f107aee585b7a6e87354ac7dcffbb96c43c79 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29215.go @@ -0,0 +1,35 @@ +// compile + +// Copyright 2018 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() { + var s string + var p, q bool + s = "a" + for p { + p = false == (true != q) + s = "" + } + _ = s == "bbb" +} + +// Another case: load from negative offset of a symbol +// in dead code (issue 30257). +func g() { + var i int + var s string + + if true { + s = "a" + } + + if f := 0.0; -f < 0 { + i = len(s[:4]) + } + + _ = s[i-1:0] != "bb" && true +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29218.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29218.go new file mode 100644 index 0000000000000000000000000000000000000000..ac9fed75f23159886fe4dce29b0518dd949ccde7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29218.go @@ -0,0 +1,24 @@ +// compile + +// Copyright 2019 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 p + +type T struct { + b bool + string +} + +func f() { + var b bool + var t T + for { + switch &t.b { + case &b: + if b { + } + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29220.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29220.go new file mode 100644 index 0000000000000000000000000000000000000000..bbfe930786e09a2009a853b1576fd08c1e25689c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29220.go @@ -0,0 +1,26 @@ +// compile + +// Copyright 2018 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 ascii(r rune) rune { + switch { + case 97 <= r && r <= 122: + return r - 32 + case 65 <= r && r <= 90: + return r + 32 + default: + return r + } +} + +func main() { + nomeObjeto := "ABE1FK21" + println(string(nomeObjeto[1:4])) + println(ascii(rune(nomeObjeto[4])) >= 48 && ascii(rune(nomeObjeto[4])) <= 57) + println(string(nomeObjeto[5])) + println(string(nomeObjeto[6:10])) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29264.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29264.go new file mode 100644 index 0000000000000000000000000000000000000000..3781559ada315a4b6f913a4ea1ee20f4583d4bc8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29264.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2018 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. + +// Verify that we emit a valid type descriptor for +// a fairly deeply nested type. + +package main + +import "fmt" +import "strings" + +func main() { + a := [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]int{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{42}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} + got := fmt.Sprint(a) + want := strings.Repeat("[", 100) + "42" + strings.Repeat("]", 100) + if got != want { + fmt.Printf("got %q\nwant %q\n", got, want) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29304.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29304.go new file mode 100644 index 0000000000000000000000000000000000000000..47bc99f9ca20e0ca50cc62ad7cf14130f33dd724 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29304.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2018 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. + +// Verify that relocation target go.builtin.error.Error +// is defined and the code links and runs correctly. + +package main + +import "errors" + +func main() { + err := errors.New("foo") + if error.Error(err) != "foo" { + panic("FAILED") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29312.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29312.go new file mode 100644 index 0000000000000000000000000000000000000000..cbf79f704c11b0d27aac175471c01d7c66fad6a2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29312.go @@ -0,0 +1,70 @@ +// run + +// Copyright 2020 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. + +// This test is not for a fix of 29312 proper, but for the patch that +// makes sure we at least don't have a security hole because of 29312. + +// This code generates lots of types. The binary should contain +// a runtime.slicetype for each of the following 253 types: +// +// []*pwn +// [][]*pwn +// ... +// [][]...[][]*pwn - 249 total "[]" +// [][]...[][][]*pwn - 250 total "[]" +// [][]...[][][][]*pwn - 251 total "[]" +// [][]...[][][][][]*pwn - 252 total "[]" +// [][]...[][][][][][]*pwn - 253 total "[]" +// +// The type names for these types are as follows. Because we truncate +// the name at depth 250, the last few names are all identical: +// +// type:[]*"".pwn +// type:[][]*"".pwn +// ... +// type:[][]...[][]*pwn - 249 total "[]" +// type:[][]...[][][]*<...> - 250 total "[]" +// type:[][]...[][][][]<...> - 251 total "[]" +// type:[][]...[][][][]<...> - 252 total "[]" (but only 251 "[]" in the name) +// type:[][]...[][][][]<...> - 253 total "[]" (but only 251 "[]" in the name) +// +// Because the names of the last 3 types are all identical, the +// compiler will generate only a single runtime.slicetype data +// structure for all 3 underlying types. It turns out the compiler +// generates just the 251-entry one. There aren't any +// runtime.slicetypes generated for the final two types. +// +// The compiler passes type:[]...[]<...> (251 total "[]") to +// fmt.Sprintf (instead of the correct 253 one). But the data +// structure at runtime actually has 253 nesting levels. So we end up +// calling String on something that is of type [][]*pwn instead of +// something of type *pwn. The way arg passing in Go works, the +// backing store pointer for the outer slice becomes the "this" +// pointer of the String method, which points to the inner []*pwn +// slice. The String method then modifies the length of that inner +// slice. +package main + +import "fmt" + +type pwn struct { + a [3]uint +} + +func (this *pwn) String() string { + this.a[1] = 7 // update length + return "" +} + +func main() { + var a pwn + s := [][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][][]*pwn{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{&a}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}} // depth 253 + fmt.Sprint(s) + n := len(s[0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0][0]) // depth 252, type []*pwn + if n != 1 { + panic(fmt.Sprintf("length was changed, want 1 got %d", n)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29329.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29329.go new file mode 100644 index 0000000000000000000000000000000000000000..07f96f431fab72660c6fe8c0d1a91335e832cc94 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29329.go @@ -0,0 +1,106 @@ +// run -race + +//go:build cgo && linux && amd64 + +// Copyright 2018 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 + +import ( + "fmt" +) + +type LineString []Point +type Point [2]float64 + +//go:noinline +func benchmarkData() LineString { + return LineString{{1.0, 2.0}} +} + +func (ls LineString) Clone() LineString { + ps := MultiPoint(ls) + return LineString(ps.Clone()) +} + +type MultiPoint []Point + +func (mp MultiPoint) Clone() MultiPoint { + if mp == nil { + return nil + } + + points := make([]Point, len(mp)) + copy(points, mp) + + return MultiPoint(points) +} + +func F1() { + cases := []struct { + threshold float64 + length int + }{ + {0.1, 1118}, + {0.5, 257}, + {1.0, 144}, + {1.5, 95}, + {2.0, 71}, + {3.0, 46}, + {4.0, 39}, + {5.0, 33}, + } + + ls := benchmarkData() + + for k := 0; k < 100; k++ { + for i, tc := range cases { + r := DouglasPeucker(tc.threshold).LineString(ls.Clone()) + if len(r) == tc.length { + fmt.Printf("%d: unexpected\n", i) + } + } + } +} + +// A DouglasPeuckerSimplifier wraps the DouglasPeucker function. +type DouglasPeuckerSimplifier struct { + Threshold float64 +} + +// DouglasPeucker creates a new DouglasPeuckerSimplifier. +func DouglasPeucker(threshold float64) *DouglasPeuckerSimplifier { + return &DouglasPeuckerSimplifier{ + Threshold: threshold, + } +} + +func (s *DouglasPeuckerSimplifier) LineString(ls LineString) LineString { + return lineString(s, ls) +} + +type simplifier interface { + simplify(LineString, bool) (LineString, []int) +} + +func lineString(s simplifier, ls LineString) LineString { + return runSimplify(s, ls) +} + +func runSimplify(s simplifier, ls LineString) LineString { + if len(ls) <= 2 { + return ls + } + ls, _ = s.simplify(ls, false) + return ls +} + +func (s *DouglasPeuckerSimplifier) simplify(ls LineString, wim bool) (LineString, []int) { + return nil, nil +} + +func main() { + F1() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29350.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29350.go new file mode 100644 index 0000000000000000000000000000000000000000..9d59f6f6c0f10b6781e94ab3628c2a9a48f45ea4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29350.go @@ -0,0 +1,9 @@ +// compile + +// Copyright 2018 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 p + +var X interface{} = 'x' diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29362.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29362.go new file mode 100644 index 0000000000000000000000000000000000000000..a8bd607c4a29b0c3b8cb6440c305c81a202e44f2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29362.go @@ -0,0 +1,42 @@ +// run + +// Copyright 2018 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. + +// Verify that we don't consider a Go'd function's +// arguments as pointers when they aren't. + +package main + +import ( + "unsafe" +) + +var badPtr uintptr + +var sink []byte + +func init() { + // Allocate large enough to use largeAlloc. + b := make([]byte, 1<<16-1) + sink = b // force heap allocation + // Any space between the object and the end of page is invalid to point to. + badPtr = uintptr(unsafe.Pointer(&b[len(b)-1])) + 1 +} + +var throttle = make(chan struct{}, 10) + +func noPointerArgs(a, b, c, d uintptr) { + sink = make([]byte, 4096) + <-throttle +} + +func main() { + const N = 1000 + for i := 0; i < N; i++ { + throttle <- struct{}{} + go noPointerArgs(badPtr, badPtr, badPtr, badPtr) + sink = make([]byte, 4096) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29362b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29362b.go new file mode 100644 index 0000000000000000000000000000000000000000..d1e3b4733f8ab338596587f500b3c04bf728c8c8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29362b.go @@ -0,0 +1,53 @@ +// run + +// Copyright 2018 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. + +// Verify that we don't consider a Go'd function's +// arguments as pointers when they aren't. + +package main + +import ( + "unsafe" +) + +var badPtr uintptr + +var sink []byte + +func init() { + // Allocate large enough to use largeAlloc. + b := make([]byte, 1<<16-1) + sink = b // force heap allocation + // Any space between the object and the end of page is invalid to point to. + badPtr = uintptr(unsafe.Pointer(&b[len(b)-1])) + 1 +} + +var throttle = make(chan struct{}, 10) + +// There are 2 arg bitmaps for this function, each with 2 bits. +// In the first, p and q are both live, so that bitmap is 11. +// In the second, only p is live, so that bitmap is 10. +// Bitmaps are byte aligned, so if the first bitmap is interpreted as +// extending across the entire argument area, we incorrectly concatenate +// the bitmaps and end up using 110000001. That bad bitmap causes a6 +// to be considered a pointer. +func noPointerArgs(p, q *byte, a0, a1, a2, a3, a4, a5, a6 uintptr) { + sink = make([]byte, 4096) + sinkptr = q + <-throttle + sinkptr = p +} + +var sinkptr *byte + +func main() { + const N = 1000 + for i := 0; i < N; i++ { + throttle <- struct{}{} + go noPointerArgs(nil, nil, badPtr, badPtr, badPtr, badPtr, badPtr, badPtr, badPtr) + sink = make([]byte, 4096) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29389.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29389.go new file mode 100644 index 0000000000000000000000000000000000000000..43859fd38f0852c6015a8f30e94c0ae952a30357 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29389.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2018 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. + +// Make sure we can correctly compile method expressions +// where the method is implicitly declared. + +package main + +import "io" + +func main() { + err := io.EOF + _ = err.Error +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29402.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29402.go new file mode 100644 index 0000000000000000000000000000000000000000..8a1f959d8428074b459fc632f9cea6f527fd16b3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29402.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2018 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. + +// Issue 29402: wrong optimization of comparison of +// constant and shift on MIPS. + +package main + +//go:noinline +func F(s []int) bool { + half := len(s) / 2 + return half >= 0 +} + +func main() { + b := F([]int{1, 2, 3, 4}) + if !b { + panic("FAIL") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29504.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29504.go new file mode 100644 index 0000000000000000000000000000000000000000..e311f84edcb263f442e2b5cc331797fa82ee0095 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29504.go @@ -0,0 +1,147 @@ +// run + +// Copyright 2019 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. + +// Make sure that in code involving indexing, the bounds +// check always fails at the line number of the '[' token. + +package main + +import ( + "fmt" + "runtime" + "strings" +) + +type T struct{ a, b, c, d, e int } // unSSAable + +func main() { + shouldPanic(func() { + var a [1]int + sink = a /*line :999999:1*/ [ /*line :100:1*/ i] + }) + shouldPanic(func() { + var a [3]int + sink = a /*line :999999:1*/ [ /*line :200:1*/ i] + }) + shouldPanic(func() { + var a []int + sink = a /*line :999999:1*/ [ /*line :300:1*/ i] + }) + shouldPanic(func() { + var a [1]int + a /*line :999999:1*/ [ /*line :400:1*/ i] = 1 + }) + shouldPanic(func() { + var a [3]int + a /*line :999999:1*/ [ /*line :500:1*/ i] = 1 + }) + shouldPanic(func() { + var a []int + a /*line :999999:1*/ [ /*line :600:1*/ i] = 1 + }) + + shouldPanic(func() { + var a [3]T + sinkT = a /*line :999999:1*/ [ /*line :700:1*/ i] + }) + shouldPanic(func() { + var a []T + sinkT = a /*line :999999:1*/ [ /*line :800:1*/ i] + }) + shouldPanic(func() { + var a [3]T + a /*line :999999:1*/ [ /*line :900:1*/ i] = T{} + }) + shouldPanic(func() { + var a []T + a /*line :999999:1*/ [ /*line :1000:1*/ i] = T{} + }) + + shouldPanic(func() { + var a [3]int + sinkS = a /*line :999999:1*/ [ /*line :1100:1*/ i:] + }) + shouldPanic(func() { + var a []int + sinkS = a /*line :999999:1*/ [ /*line :1200:1*/ i:] + }) + shouldPanic(func() { + var a [3]int + sinkS = a /*line :999999:1*/ [: /*line :1300:1*/ i] + }) + shouldPanic(func() { + var a []int + sinkS = a /*line :999999:1*/ [: /*line :1400:1*/ i] + }) + + shouldPanic(func() { + var a [3]T + sinkST = a /*line :999999:1*/ [ /*line :1500:1*/ i:] + }) + shouldPanic(func() { + var a []T + sinkST = a /*line :999999:1*/ [ /*line :1600:1*/ i:] + }) + shouldPanic(func() { + var a [3]T + sinkST = a /*line :999999:1*/ [: /*line :1700:1*/ i] + }) + shouldPanic(func() { + var a []T + sinkST = a /*line :999999:1*/ [: /*line :1800:1*/ i] + }) + + shouldPanic(func() { + s := "foo" + sinkB = s /*line :999999:1*/ [ /*line :1900:1*/ i] + }) + shouldPanic(func() { + s := "foo" + sinkStr = s /*line :999999:1*/ [ /*line :2000:1*/ i:] + }) + shouldPanic(func() { + s := "foo" + sinkStr = s /*line :999999:1*/ [: /*line :2100:1*/ i] + }) + + if bad { + panic("ERRORS") + } +} + +var i = 9 +var sink int +var sinkS []int +var sinkT T +var sinkST []T +var sinkB byte +var sinkStr string + +var bad = false + +func shouldPanic(f func()) { + defer func() { + if recover() == nil { + panic("did not panic") + } + var pcs [10]uintptr + n := runtime.Callers(1, pcs[:]) + iter := runtime.CallersFrames(pcs[:n]) + buf := "" + for { + frame, more := iter.Next() + buf += fmt.Sprintf("%s:%d %s\n", frame.File, frame.Line, frame.Function) + if !more { + break + } + } + if !strings.Contains(buf, "999999") { + fmt.Printf("could not find marker line in traceback:\n%s\n", buf) + bad = true + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29562.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29562.go new file mode 100644 index 0000000000000000000000000000000000000000..cbcd77d5df76b062c5eda1a83e3a5c519d977831 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29562.go @@ -0,0 +1,26 @@ +// compile + +// Copyright 2019 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. + +// Triggers a double walk of the (inlined) switch in il + +package p + +func il(s string) string { + switch len(s) { + case 0: + return "zero" + case 1: + return "one" + } + return s +} + +func f() { + var s string + var as []string + switch false && (s+"a"+as[0]+il(s)+as[0]+s == "") { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29610.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29610.go new file mode 100644 index 0000000000000000000000000000000000000000..8d49ba6b8c19c38532946d3bccb26b6f381ca5b4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29610.go @@ -0,0 +1,13 @@ +// rundir + +// Copyright 2018 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. + +// Issue 29610: Symbol import and initialization order caused function +// symbols to be recorded as non-function symbols. + +// This uses rundir not because we actually want to run the final +// binary, but because we need to at least link it. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29612.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29612.go new file mode 100644 index 0000000000000000000000000000000000000000..87c96b480fb7a9a4fe21effca7454f3cec30b715 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29612.go @@ -0,0 +1,7 @@ +// runindir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29735.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29735.go new file mode 100644 index 0000000000000000000000000000000000000000..7a0381d533effcf5f8b8b52c81c435186fdde8c7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29735.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2019 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. + +// Make sure FuncForPC won't panic when given a pc which +// lies between two functions. + +package main + +import ( + "runtime" +) + +func main() { + var stack [1]uintptr + runtime.Callers(1, stack[:]) + f() // inlined function, to give main some inlining info + for i := uintptr(0); true; i++ { + f := runtime.FuncForPC(stack[0] + i) + if f.Name() != "main.main" && f.Name() != "main.f" { + // Reached next function successfully. + break + } + } +} + +func f() { + sink = 0 // one instruction which can't be removed +} + +var sink int diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29855.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29855.go new file mode 100644 index 0000000000000000000000000000000000000000..402093c160257ce9a0b7c52e0a5c32dfe015c251 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29855.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2018 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 + +type T struct { + GlobalName string +} + +var t = T{Name: "foo"} // ERROR "unknown field 'Name' in struct literal of type T|unknown field .*Name.* in .*T" + +func (t T) Name() string { + return t.GlobalName +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29870.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29870.go new file mode 100644 index 0000000000000000000000000000000000000000..b79860ca2bb9ed71d5bf28926029a9fc46771427 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29870.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2019 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. + +// Make sure we can compile "_" functions without crashing. + +package main + +import "log" + +func _() { + log.Println("%2F") +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29870b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29870b.go new file mode 100644 index 0000000000000000000000000000000000000000..c7cdd8c8c77d74bb5e8e177d4de6fa5d2cd7b4bb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29870b.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2019 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. + +// Make sure we're compiling "_" functions at least enough +// to get to an error which is generated during walk. + +package main + +func _() { + x := 7 // ERROR ".*x.* declared and not used" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29919.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29919.go new file mode 100644 index 0000000000000000000000000000000000000000..6d97592c11871dde94f0d1b55451041aa5f38d5f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29919.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2019 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. + +// Make sure tracebacks from initialization code are reported correctly. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue29943.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue29943.go new file mode 100644 index 0000000000000000000000000000000000000000..ff47de55d524e23b12c8aa2569419d89b103aeb5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue29943.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2019 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. + +// Code was miscompiled on ppc64le due to incorrect zero-extension +// that was CSE'd. + +package main + +//go:noinline +func g(i uint64) uint64 { + return uint64(uint32(i)) +} + +var sink uint64 + +func main() { + for i := uint64(0); i < 1; i++ { + i32 := int32(i - 1) + sink = uint64((uint32(i32) << 1) ^ uint32((i32 >> 31))) + x := g(uint64(i32)) + if x != uint64(uint32(i32)) { + panic(x) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30041.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30041.go new file mode 100644 index 0000000000000000000000000000000000000000..7d8a1698cbc2882e2e7b3a06cd7007d642752b08 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30041.go @@ -0,0 +1,63 @@ +// run + +// Copyright 2019 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. + +// Issue 30041: copying results of a reflect-generated +// call on stack should not have write barrier. + +package main + +import ( + "reflect" + "runtime" + "unsafe" +) + +var badPtr uintptr + +var sink []byte + +func init() { + // Allocate large enough to use largeAlloc. + b := make([]byte, 1<<16-1) + sink = b // force heap allocation + // Any space between the object and the end of page is invalid to point to. + badPtr = uintptr(unsafe.Pointer(&b[len(b)-1])) + 1 +} + +type ft func() *int + +var fn ft + +func rf([]reflect.Value) []reflect.Value { + a := reflect.ValueOf((*int)(nil)) + return []reflect.Value{a} +} + +const N = 1000 + +func main() { + fn = reflect.MakeFunc(reflect.TypeOf(fn), rf).Interface().(ft) + + // Keep running GC so the write barrier is on. + go func() { + for i := 0; i < N; i++ { + runtime.GC() + } + }() + + var x [10]uintptr + for i := range x { + x[i] = badPtr + } + for i := 0; i < N; i++ { + runtime.Gosched() + use(x) // prepare bad pointers on stack + fn() + } +} + +//go:noinline +func use([10]uintptr) {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30061.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30061.go new file mode 100644 index 0000000000000000000000000000000000000000..5092b01799ef0fd3929c97dc4c3c6bf3fe21a254 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30061.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2019 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. + +// Make sure we can linkname to memmove with an unsafe.Pointer argument. + +package p + +import "unsafe" + +//go:linkname memmove runtime.memmove +func memmove(to, from unsafe.Pointer, n uintptr) + +var V1, V2 int + +func F() { + memmove(unsafe.Pointer(&V1), unsafe.Pointer(&V2), unsafe.Sizeof(int(0))) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30085.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30085.go new file mode 100644 index 0000000000000000000000000000000000000000..f8595ab90c4bac78aa91cc6d505ec278160d37a8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30085.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2019 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 main() { + var c, d = 1, 2, 3 // ERROR "assignment mismatch: 2 variables but 3 values|wrong number of initializations|extra init expr" + var e, f, g = 1, 2 // ERROR "assignment mismatch: 3 variables but 2 values|wrong number of initializations|missing init expr" + _, _, _, _, _ = c, d, e, f, g +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30087.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30087.go new file mode 100644 index 0000000000000000000000000000000000000000..c55c47b06486bfc00e16701dd6b92604cf044ae4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30087.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2019 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 main() { + var a, b = 1 // ERROR "assignment mismatch: 2 variables but 1 value|wrong number of initializations|cannot initialize" + _ = 1, 2 // ERROR "assignment mismatch: 1 variable but 2 values|number of variables does not match|cannot assign" + c, d := 1 // ERROR "assignment mismatch: 2 variables but 1 value|wrong number of initializations|cannot initialize" + e, f := 1, 2, 3 // ERROR "assignment mismatch: 2 variables but 3 values|wrong number of initializations|cannot initialize" + _, _, _, _, _, _ = a, b, c, d, e, f +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30116.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116.go new file mode 100644 index 0000000000000000000000000000000000000000..452a6e3ae80a7355e97558936ae6d3ec6f090467 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116.go @@ -0,0 +1,112 @@ +// run + +// Copyright 2019 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. + +// This test makes sure the text output for bounds check failures is as expected. + +package main + +import ( + "fmt" + "os" + "runtime" + "text/tabwriter" +) + +// Testing with length 3 slices, arrays, and strings. +// Large (>1<<32) values are included to test 32-bit platforms. +var indexes = []int64{-9876543210, -1, 0, 2, 3, 9876543210} +var slices = []int64{-9876543210, -1, 0, 3, 4, 9876543210} + +var w *tabwriter.Writer + +func main() { + w = tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.AlignRight) + defer w.Flush() + doIndex() + doSlice() + doSlice3() +} +func doIndex() { + a := []int{1, 2, 3} + for _, i := range indexes { + printPanic(fmt.Sprintf("slice[%d]", i), func() { + _ = a[i] + }) + } + b := [3]int{1, 2, 3} + for _, i := range indexes { + printPanic(fmt.Sprintf("array[%d]", i), func() { + _ = b[i] + }) + } + c := "123" + for _, i := range indexes { + printPanic(fmt.Sprintf("string[%d]", i), func() { + _ = c[i] + }) + } +} + +func doSlice() { + a := []int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + printPanic(fmt.Sprintf("slice[%d:%d]", i, j), func() { + _ = a[i:j] + }) + } + } + b := [3]int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + printPanic(fmt.Sprintf("array[%d:%d]", i, j), func() { + _ = b[i:j] + }) + } + } + c := "123" + for _, i := range slices { + for _, j := range slices { + printPanic(fmt.Sprintf("string[%d:%d]", i, j), func() { + _ = c[i:j] + }) + } + } +} + +func doSlice3() { + a := []int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + for _, k := range slices { + printPanic(fmt.Sprintf("slice[%d:%d:%d]", i, j, k), func() { + _ = a[i:j:k] + }) + } + } + } + b := [3]int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + for _, k := range slices { + printPanic(fmt.Sprintf("array[%d:%d:%d]", i, j, k), func() { + _ = b[i:j:k] + }) + } + } + } +} + +func printPanic(msg string, f func()) { + defer func() { + res := "no panic" + if e := recover(); e != nil { + res = e.(runtime.Error).Error() + } + fmt.Fprintf(w, "%s\t %s\n", msg, res) + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30116.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116.out new file mode 100644 index 0000000000000000000000000000000000000000..bde134d9509f57c2c5dc012979c34976e2d4fcfa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116.out @@ -0,0 +1,558 @@ + slice[-9876543210] runtime error: index out of range [-9876543210] + slice[-1] runtime error: index out of range [-1] + slice[0] no panic + slice[2] no panic + slice[3] runtime error: index out of range [3] with length 3 + slice[9876543210] runtime error: index out of range [9876543210] with length 3 + array[-9876543210] runtime error: index out of range [-9876543210] + array[-1] runtime error: index out of range [-1] + array[0] no panic + array[2] no panic + array[3] runtime error: index out of range [3] with length 3 + array[9876543210] runtime error: index out of range [9876543210] with length 3 + string[-9876543210] runtime error: index out of range [-9876543210] + string[-1] runtime error: index out of range [-1] + string[0] no panic + string[2] no panic + string[3] runtime error: index out of range [3] with length 3 + string[9876543210] runtime error: index out of range [9876543210] with length 3 + slice[-9876543210:-9876543210] runtime error: slice bounds out of range [:-9876543210] + slice[-9876543210:-1] runtime error: slice bounds out of range [:-1] + slice[-9876543210:0] runtime error: slice bounds out of range [-9876543210:] + slice[-9876543210:3] runtime error: slice bounds out of range [-9876543210:] + slice[-9876543210:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[-9876543210:9876543210] runtime error: slice bounds out of range [:9876543210] with capacity 3 + slice[-1:-9876543210] runtime error: slice bounds out of range [:-9876543210] + slice[-1:-1] runtime error: slice bounds out of range [:-1] + slice[-1:0] runtime error: slice bounds out of range [-1:] + slice[-1:3] runtime error: slice bounds out of range [-1:] + slice[-1:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[-1:9876543210] runtime error: slice bounds out of range [:9876543210] with capacity 3 + slice[0:-9876543210] runtime error: slice bounds out of range [:-9876543210] + slice[0:-1] runtime error: slice bounds out of range [:-1] + slice[0:0] no panic + slice[0:3] no panic + slice[0:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[0:9876543210] runtime error: slice bounds out of range [:9876543210] with capacity 3 + slice[3:-9876543210] runtime error: slice bounds out of range [:-9876543210] + slice[3:-1] runtime error: slice bounds out of range [:-1] + slice[3:0] runtime error: slice bounds out of range [3:0] + slice[3:3] no panic + slice[3:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[3:9876543210] runtime error: slice bounds out of range [:9876543210] with capacity 3 + slice[4:-9876543210] runtime error: slice bounds out of range [:-9876543210] + slice[4:-1] runtime error: slice bounds out of range [:-1] + slice[4:0] runtime error: slice bounds out of range [4:0] + slice[4:3] runtime error: slice bounds out of range [4:3] + slice[4:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[4:9876543210] runtime error: slice bounds out of range [:9876543210] with capacity 3 + slice[9876543210:-9876543210] runtime error: slice bounds out of range [:-9876543210] + slice[9876543210:-1] runtime error: slice bounds out of range [:-1] + slice[9876543210:0] runtime error: slice bounds out of range [9876543210:0] + slice[9876543210:3] runtime error: slice bounds out of range [9876543210:3] + slice[9876543210:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[9876543210:9876543210] runtime error: slice bounds out of range [:9876543210] with capacity 3 + array[-9876543210:-9876543210] runtime error: slice bounds out of range [:-9876543210] + array[-9876543210:-1] runtime error: slice bounds out of range [:-1] + array[-9876543210:0] runtime error: slice bounds out of range [-9876543210:] + array[-9876543210:3] runtime error: slice bounds out of range [-9876543210:] + array[-9876543210:4] runtime error: slice bounds out of range [:4] with length 3 + array[-9876543210:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + array[-1:-9876543210] runtime error: slice bounds out of range [:-9876543210] + array[-1:-1] runtime error: slice bounds out of range [:-1] + array[-1:0] runtime error: slice bounds out of range [-1:] + array[-1:3] runtime error: slice bounds out of range [-1:] + array[-1:4] runtime error: slice bounds out of range [:4] with length 3 + array[-1:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + array[0:-9876543210] runtime error: slice bounds out of range [:-9876543210] + array[0:-1] runtime error: slice bounds out of range [:-1] + array[0:0] no panic + array[0:3] no panic + array[0:4] runtime error: slice bounds out of range [:4] with length 3 + array[0:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + array[3:-9876543210] runtime error: slice bounds out of range [:-9876543210] + array[3:-1] runtime error: slice bounds out of range [:-1] + array[3:0] runtime error: slice bounds out of range [3:0] + array[3:3] no panic + array[3:4] runtime error: slice bounds out of range [:4] with length 3 + array[3:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + array[4:-9876543210] runtime error: slice bounds out of range [:-9876543210] + array[4:-1] runtime error: slice bounds out of range [:-1] + array[4:0] runtime error: slice bounds out of range [4:0] + array[4:3] runtime error: slice bounds out of range [4:3] + array[4:4] runtime error: slice bounds out of range [:4] with length 3 + array[4:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + array[9876543210:-9876543210] runtime error: slice bounds out of range [:-9876543210] + array[9876543210:-1] runtime error: slice bounds out of range [:-1] + array[9876543210:0] runtime error: slice bounds out of range [9876543210:0] + array[9876543210:3] runtime error: slice bounds out of range [9876543210:3] + array[9876543210:4] runtime error: slice bounds out of range [:4] with length 3 + array[9876543210:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + string[-9876543210:-9876543210] runtime error: slice bounds out of range [:-9876543210] + string[-9876543210:-1] runtime error: slice bounds out of range [:-1] + string[-9876543210:0] runtime error: slice bounds out of range [-9876543210:] + string[-9876543210:3] runtime error: slice bounds out of range [-9876543210:] + string[-9876543210:4] runtime error: slice bounds out of range [:4] with length 3 + string[-9876543210:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + string[-1:-9876543210] runtime error: slice bounds out of range [:-9876543210] + string[-1:-1] runtime error: slice bounds out of range [:-1] + string[-1:0] runtime error: slice bounds out of range [-1:] + string[-1:3] runtime error: slice bounds out of range [-1:] + string[-1:4] runtime error: slice bounds out of range [:4] with length 3 + string[-1:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + string[0:-9876543210] runtime error: slice bounds out of range [:-9876543210] + string[0:-1] runtime error: slice bounds out of range [:-1] + string[0:0] no panic + string[0:3] no panic + string[0:4] runtime error: slice bounds out of range [:4] with length 3 + string[0:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + string[3:-9876543210] runtime error: slice bounds out of range [:-9876543210] + string[3:-1] runtime error: slice bounds out of range [:-1] + string[3:0] runtime error: slice bounds out of range [3:0] + string[3:3] no panic + string[3:4] runtime error: slice bounds out of range [:4] with length 3 + string[3:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + string[4:-9876543210] runtime error: slice bounds out of range [:-9876543210] + string[4:-1] runtime error: slice bounds out of range [:-1] + string[4:0] runtime error: slice bounds out of range [4:0] + string[4:3] runtime error: slice bounds out of range [4:3] + string[4:4] runtime error: slice bounds out of range [:4] with length 3 + string[4:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + string[9876543210:-9876543210] runtime error: slice bounds out of range [:-9876543210] + string[9876543210:-1] runtime error: slice bounds out of range [:-1] + string[9876543210:0] runtime error: slice bounds out of range [9876543210:0] + string[9876543210:3] runtime error: slice bounds out of range [9876543210:3] + string[9876543210:4] runtime error: slice bounds out of range [:4] with length 3 + string[9876543210:9876543210] runtime error: slice bounds out of range [:9876543210] with length 3 + slice[-9876543210:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-9876543210:-9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[-9876543210:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + slice[-9876543210:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + slice[-9876543210:-9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-9876543210:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-9876543210:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-9876543210:-1:-1] runtime error: slice bounds out of range [::-1] + slice[-9876543210:-1:0] runtime error: slice bounds out of range [:-1:] + slice[-9876543210:-1:3] runtime error: slice bounds out of range [:-1:] + slice[-9876543210:-1:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-9876543210:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-9876543210:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-9876543210:0:-1] runtime error: slice bounds out of range [::-1] + slice[-9876543210:0:0] runtime error: slice bounds out of range [-9876543210::] + slice[-9876543210:0:3] runtime error: slice bounds out of range [-9876543210::] + slice[-9876543210:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-9876543210:0:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-9876543210:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-9876543210:3:-1] runtime error: slice bounds out of range [::-1] + slice[-9876543210:3:0] runtime error: slice bounds out of range [:3:0] + slice[-9876543210:3:3] runtime error: slice bounds out of range [-9876543210::] + slice[-9876543210:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-9876543210:3:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-9876543210:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-9876543210:4:-1] runtime error: slice bounds out of range [::-1] + slice[-9876543210:4:0] runtime error: slice bounds out of range [:4:0] + slice[-9876543210:4:3] runtime error: slice bounds out of range [:4:3] + slice[-9876543210:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-9876543210:4:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-9876543210:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-9876543210:9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[-9876543210:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + slice[-9876543210:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + slice[-9876543210:9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-9876543210:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-1:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-1:-9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[-1:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + slice[-1:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + slice[-1:-9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-1:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-1:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-1:-1:-1] runtime error: slice bounds out of range [::-1] + slice[-1:-1:0] runtime error: slice bounds out of range [:-1:] + slice[-1:-1:3] runtime error: slice bounds out of range [:-1:] + slice[-1:-1:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-1:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-1:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-1:0:-1] runtime error: slice bounds out of range [::-1] + slice[-1:0:0] runtime error: slice bounds out of range [-1::] + slice[-1:0:3] runtime error: slice bounds out of range [-1::] + slice[-1:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-1:0:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-1:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-1:3:-1] runtime error: slice bounds out of range [::-1] + slice[-1:3:0] runtime error: slice bounds out of range [:3:0] + slice[-1:3:3] runtime error: slice bounds out of range [-1::] + slice[-1:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-1:3:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-1:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-1:4:-1] runtime error: slice bounds out of range [::-1] + slice[-1:4:0] runtime error: slice bounds out of range [:4:0] + slice[-1:4:3] runtime error: slice bounds out of range [:4:3] + slice[-1:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-1:4:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[-1:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[-1:9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[-1:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + slice[-1:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + slice[-1:9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[-1:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[0:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[0:-9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[0:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + slice[0:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + slice[0:-9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[0:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[0:-1:-1] runtime error: slice bounds out of range [::-1] + slice[0:-1:0] runtime error: slice bounds out of range [:-1:] + slice[0:-1:3] runtime error: slice bounds out of range [:-1:] + slice[0:-1:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[0:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[0:0:-1] runtime error: slice bounds out of range [::-1] + slice[0:0:0] no panic + slice[0:0:3] no panic + slice[0:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:0:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[0:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[0:3:-1] runtime error: slice bounds out of range [::-1] + slice[0:3:0] runtime error: slice bounds out of range [:3:0] + slice[0:3:3] no panic + slice[0:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:3:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[0:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[0:4:-1] runtime error: slice bounds out of range [::-1] + slice[0:4:0] runtime error: slice bounds out of range [:4:0] + slice[0:4:3] runtime error: slice bounds out of range [:4:3] + slice[0:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:4:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[0:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[0:9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[0:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + slice[0:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + slice[0:9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[3:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[3:-9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[3:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + slice[3:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + slice[3:-9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[3:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[3:-1:-1] runtime error: slice bounds out of range [::-1] + slice[3:-1:0] runtime error: slice bounds out of range [:-1:] + slice[3:-1:3] runtime error: slice bounds out of range [:-1:] + slice[3:-1:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[3:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[3:0:-1] runtime error: slice bounds out of range [::-1] + slice[3:0:0] runtime error: slice bounds out of range [3:0:] + slice[3:0:3] runtime error: slice bounds out of range [3:0:] + slice[3:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:0:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[3:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[3:3:-1] runtime error: slice bounds out of range [::-1] + slice[3:3:0] runtime error: slice bounds out of range [:3:0] + slice[3:3:3] no panic + slice[3:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:3:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[3:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[3:4:-1] runtime error: slice bounds out of range [::-1] + slice[3:4:0] runtime error: slice bounds out of range [:4:0] + slice[3:4:3] runtime error: slice bounds out of range [:4:3] + slice[3:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:4:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[3:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[3:9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[3:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + slice[3:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + slice[3:9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[4:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[4:-9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[4:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + slice[4:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + slice[4:-9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[4:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[4:-1:-1] runtime error: slice bounds out of range [::-1] + slice[4:-1:0] runtime error: slice bounds out of range [:-1:] + slice[4:-1:3] runtime error: slice bounds out of range [:-1:] + slice[4:-1:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[4:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[4:0:-1] runtime error: slice bounds out of range [::-1] + slice[4:0:0] runtime error: slice bounds out of range [4:0:] + slice[4:0:3] runtime error: slice bounds out of range [4:0:] + slice[4:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:0:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[4:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[4:3:-1] runtime error: slice bounds out of range [::-1] + slice[4:3:0] runtime error: slice bounds out of range [:3:0] + slice[4:3:3] runtime error: slice bounds out of range [4:3:] + slice[4:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:3:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[4:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[4:4:-1] runtime error: slice bounds out of range [::-1] + slice[4:4:0] runtime error: slice bounds out of range [:4:0] + slice[4:4:3] runtime error: slice bounds out of range [:4:3] + slice[4:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:4:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[4:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[4:9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[4:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + slice[4:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + slice[4:9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[9876543210:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[9876543210:-9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[9876543210:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + slice[9876543210:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + slice[9876543210:-9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[9876543210:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[9876543210:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[9876543210:-1:-1] runtime error: slice bounds out of range [::-1] + slice[9876543210:-1:0] runtime error: slice bounds out of range [:-1:] + slice[9876543210:-1:3] runtime error: slice bounds out of range [:-1:] + slice[9876543210:-1:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[9876543210:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[9876543210:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[9876543210:0:-1] runtime error: slice bounds out of range [::-1] + slice[9876543210:0:0] runtime error: slice bounds out of range [9876543210:0:] + slice[9876543210:0:3] runtime error: slice bounds out of range [9876543210:0:] + slice[9876543210:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[9876543210:0:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[9876543210:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[9876543210:3:-1] runtime error: slice bounds out of range [::-1] + slice[9876543210:3:0] runtime error: slice bounds out of range [:3:0] + slice[9876543210:3:3] runtime error: slice bounds out of range [9876543210:3:] + slice[9876543210:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[9876543210:3:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[9876543210:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[9876543210:4:-1] runtime error: slice bounds out of range [::-1] + slice[9876543210:4:0] runtime error: slice bounds out of range [:4:0] + slice[9876543210:4:3] runtime error: slice bounds out of range [:4:3] + slice[9876543210:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[9876543210:4:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + slice[9876543210:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + slice[9876543210:9876543210:-1] runtime error: slice bounds out of range [::-1] + slice[9876543210:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + slice[9876543210:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + slice[9876543210:9876543210:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[9876543210:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with capacity 3 + array[-9876543210:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-9876543210:-9876543210:-1] runtime error: slice bounds out of range [::-1] + array[-9876543210:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + array[-9876543210:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + array[-9876543210:-9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[-9876543210:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-9876543210:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-9876543210:-1:-1] runtime error: slice bounds out of range [::-1] + array[-9876543210:-1:0] runtime error: slice bounds out of range [:-1:] + array[-9876543210:-1:3] runtime error: slice bounds out of range [:-1:] + array[-9876543210:-1:4] runtime error: slice bounds out of range [::4] with length 3 + array[-9876543210:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-9876543210:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-9876543210:0:-1] runtime error: slice bounds out of range [::-1] + array[-9876543210:0:0] runtime error: slice bounds out of range [-9876543210::] + array[-9876543210:0:3] runtime error: slice bounds out of range [-9876543210::] + array[-9876543210:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[-9876543210:0:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-9876543210:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-9876543210:3:-1] runtime error: slice bounds out of range [::-1] + array[-9876543210:3:0] runtime error: slice bounds out of range [:3:0] + array[-9876543210:3:3] runtime error: slice bounds out of range [-9876543210::] + array[-9876543210:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[-9876543210:3:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-9876543210:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-9876543210:4:-1] runtime error: slice bounds out of range [::-1] + array[-9876543210:4:0] runtime error: slice bounds out of range [:4:0] + array[-9876543210:4:3] runtime error: slice bounds out of range [:4:3] + array[-9876543210:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[-9876543210:4:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-9876543210:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-9876543210:9876543210:-1] runtime error: slice bounds out of range [::-1] + array[-9876543210:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + array[-9876543210:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + array[-9876543210:9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[-9876543210:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-1:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-1:-9876543210:-1] runtime error: slice bounds out of range [::-1] + array[-1:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + array[-1:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + array[-1:-9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[-1:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-1:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-1:-1:-1] runtime error: slice bounds out of range [::-1] + array[-1:-1:0] runtime error: slice bounds out of range [:-1:] + array[-1:-1:3] runtime error: slice bounds out of range [:-1:] + array[-1:-1:4] runtime error: slice bounds out of range [::4] with length 3 + array[-1:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-1:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-1:0:-1] runtime error: slice bounds out of range [::-1] + array[-1:0:0] runtime error: slice bounds out of range [-1::] + array[-1:0:3] runtime error: slice bounds out of range [-1::] + array[-1:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[-1:0:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-1:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-1:3:-1] runtime error: slice bounds out of range [::-1] + array[-1:3:0] runtime error: slice bounds out of range [:3:0] + array[-1:3:3] runtime error: slice bounds out of range [-1::] + array[-1:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[-1:3:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-1:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-1:4:-1] runtime error: slice bounds out of range [::-1] + array[-1:4:0] runtime error: slice bounds out of range [:4:0] + array[-1:4:3] runtime error: slice bounds out of range [:4:3] + array[-1:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[-1:4:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[-1:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[-1:9876543210:-1] runtime error: slice bounds out of range [::-1] + array[-1:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + array[-1:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + array[-1:9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[-1:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[0:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[0:-9876543210:-1] runtime error: slice bounds out of range [::-1] + array[0:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + array[0:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + array[0:-9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[0:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[0:-1:-1] runtime error: slice bounds out of range [::-1] + array[0:-1:0] runtime error: slice bounds out of range [:-1:] + array[0:-1:3] runtime error: slice bounds out of range [:-1:] + array[0:-1:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[0:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[0:0:-1] runtime error: slice bounds out of range [::-1] + array[0:0:0] no panic + array[0:0:3] no panic + array[0:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:0:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[0:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[0:3:-1] runtime error: slice bounds out of range [::-1] + array[0:3:0] runtime error: slice bounds out of range [:3:0] + array[0:3:3] no panic + array[0:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:3:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[0:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[0:4:-1] runtime error: slice bounds out of range [::-1] + array[0:4:0] runtime error: slice bounds out of range [:4:0] + array[0:4:3] runtime error: slice bounds out of range [:4:3] + array[0:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:4:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[0:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[0:9876543210:-1] runtime error: slice bounds out of range [::-1] + array[0:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + array[0:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + array[0:9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[3:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[3:-9876543210:-1] runtime error: slice bounds out of range [::-1] + array[3:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + array[3:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + array[3:-9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[3:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[3:-1:-1] runtime error: slice bounds out of range [::-1] + array[3:-1:0] runtime error: slice bounds out of range [:-1:] + array[3:-1:3] runtime error: slice bounds out of range [:-1:] + array[3:-1:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[3:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[3:0:-1] runtime error: slice bounds out of range [::-1] + array[3:0:0] runtime error: slice bounds out of range [3:0:] + array[3:0:3] runtime error: slice bounds out of range [3:0:] + array[3:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:0:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[3:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[3:3:-1] runtime error: slice bounds out of range [::-1] + array[3:3:0] runtime error: slice bounds out of range [:3:0] + array[3:3:3] no panic + array[3:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:3:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[3:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[3:4:-1] runtime error: slice bounds out of range [::-1] + array[3:4:0] runtime error: slice bounds out of range [:4:0] + array[3:4:3] runtime error: slice bounds out of range [:4:3] + array[3:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:4:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[3:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[3:9876543210:-1] runtime error: slice bounds out of range [::-1] + array[3:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + array[3:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + array[3:9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[4:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[4:-9876543210:-1] runtime error: slice bounds out of range [::-1] + array[4:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + array[4:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + array[4:-9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[4:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[4:-1:-1] runtime error: slice bounds out of range [::-1] + array[4:-1:0] runtime error: slice bounds out of range [:-1:] + array[4:-1:3] runtime error: slice bounds out of range [:-1:] + array[4:-1:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[4:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[4:0:-1] runtime error: slice bounds out of range [::-1] + array[4:0:0] runtime error: slice bounds out of range [4:0:] + array[4:0:3] runtime error: slice bounds out of range [4:0:] + array[4:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:0:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[4:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[4:3:-1] runtime error: slice bounds out of range [::-1] + array[4:3:0] runtime error: slice bounds out of range [:3:0] + array[4:3:3] runtime error: slice bounds out of range [4:3:] + array[4:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:3:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[4:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[4:4:-1] runtime error: slice bounds out of range [::-1] + array[4:4:0] runtime error: slice bounds out of range [:4:0] + array[4:4:3] runtime error: slice bounds out of range [:4:3] + array[4:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:4:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[4:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[4:9876543210:-1] runtime error: slice bounds out of range [::-1] + array[4:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + array[4:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + array[4:9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[9876543210:-9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[9876543210:-9876543210:-1] runtime error: slice bounds out of range [::-1] + array[9876543210:-9876543210:0] runtime error: slice bounds out of range [:-9876543210:] + array[9876543210:-9876543210:3] runtime error: slice bounds out of range [:-9876543210:] + array[9876543210:-9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[9876543210:-9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[9876543210:-1:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[9876543210:-1:-1] runtime error: slice bounds out of range [::-1] + array[9876543210:-1:0] runtime error: slice bounds out of range [:-1:] + array[9876543210:-1:3] runtime error: slice bounds out of range [:-1:] + array[9876543210:-1:4] runtime error: slice bounds out of range [::4] with length 3 + array[9876543210:-1:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[9876543210:0:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[9876543210:0:-1] runtime error: slice bounds out of range [::-1] + array[9876543210:0:0] runtime error: slice bounds out of range [9876543210:0:] + array[9876543210:0:3] runtime error: slice bounds out of range [9876543210:0:] + array[9876543210:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[9876543210:0:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[9876543210:3:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[9876543210:3:-1] runtime error: slice bounds out of range [::-1] + array[9876543210:3:0] runtime error: slice bounds out of range [:3:0] + array[9876543210:3:3] runtime error: slice bounds out of range [9876543210:3:] + array[9876543210:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[9876543210:3:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[9876543210:4:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[9876543210:4:-1] runtime error: slice bounds out of range [::-1] + array[9876543210:4:0] runtime error: slice bounds out of range [:4:0] + array[9876543210:4:3] runtime error: slice bounds out of range [:4:3] + array[9876543210:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[9876543210:4:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 + array[9876543210:9876543210:-9876543210] runtime error: slice bounds out of range [::-9876543210] + array[9876543210:9876543210:-1] runtime error: slice bounds out of range [::-1] + array[9876543210:9876543210:0] runtime error: slice bounds out of range [:9876543210:0] + array[9876543210:9876543210:3] runtime error: slice bounds out of range [:9876543210:3] + array[9876543210:9876543210:4] runtime error: slice bounds out of range [::4] with length 3 + array[9876543210:9876543210:9876543210] runtime error: slice bounds out of range [::9876543210] with length 3 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30116u.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116u.go new file mode 100644 index 0000000000000000000000000000000000000000..7c2aea2cd4871bd76662b2ce6f114d168e14db64 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116u.go @@ -0,0 +1,112 @@ +// run + +// Copyright 2019 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. + +// This test makes sure the text output for bounds check failures is as expected. + +package main + +import ( + "fmt" + "os" + "runtime" + "text/tabwriter" +) + +// Testing with length 3 slices, arrays, and strings. +// A large (>1<<32) value is included to test 32-bit platforms. +var indexes = []uint64{0, 2, 3, 1<<32 - 1, 1<<64 - 1} +var slices = []uint64{0, 3, 4, 1<<32 - 1, 1<<64 - 1} + +var w *tabwriter.Writer + +func main() { + w = tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.AlignRight) + defer w.Flush() + doIndex() + doSlice() + doSlice3() +} +func doIndex() { + a := []int{1, 2, 3} + for _, i := range indexes { + printPanic(fmt.Sprintf("slice[%d]", i), func() { + _ = a[i] + }) + } + b := [3]int{1, 2, 3} + for _, i := range indexes { + printPanic(fmt.Sprintf("array[%d]", i), func() { + _ = b[i] + }) + } + c := "123" + for _, i := range indexes { + printPanic(fmt.Sprintf("string[%d]", i), func() { + _ = c[i] + }) + } +} + +func doSlice() { + a := []int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + printPanic(fmt.Sprintf("slice[%d:%d]", i, j), func() { + _ = a[i:j] + }) + } + } + b := [3]int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + printPanic(fmt.Sprintf("array[%d:%d]", i, j), func() { + _ = b[i:j] + }) + } + } + c := "123" + for _, i := range slices { + for _, j := range slices { + printPanic(fmt.Sprintf("string[%d:%d]", i, j), func() { + _ = c[i:j] + }) + } + } +} + +func doSlice3() { + a := []int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + for _, k := range slices { + printPanic(fmt.Sprintf("slice[%d:%d:%d]", i, j, k), func() { + _ = a[i:j:k] + }) + } + } + } + b := [3]int{1, 2, 3} + for _, i := range slices { + for _, j := range slices { + for _, k := range slices { + printPanic(fmt.Sprintf("array[%d:%d:%d]", i, j, k), func() { + _ = b[i:j:k] + }) + } + } + } +} + +func printPanic(msg string, f func()) { + defer func() { + res := "no panic" + if e := recover(); e != nil { + res = e.(runtime.Error).Error() + } + fmt.Fprintf(w, "%s\t %s\n", msg, res) + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30116u.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116u.out new file mode 100644 index 0000000000000000000000000000000000000000..ee19192aaab87a3896973e8fc4643fce098bdf07 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30116u.out @@ -0,0 +1,340 @@ + slice[0] no panic + slice[2] no panic + slice[3] runtime error: index out of range [3] with length 3 + slice[4294967295] runtime error: index out of range [4294967295] with length 3 + slice[18446744073709551615] runtime error: index out of range [18446744073709551615] with length 3 + array[0] no panic + array[2] no panic + array[3] runtime error: index out of range [3] with length 3 + array[4294967295] runtime error: index out of range [4294967295] with length 3 + array[18446744073709551615] runtime error: index out of range [18446744073709551615] with length 3 + string[0] no panic + string[2] no panic + string[3] runtime error: index out of range [3] with length 3 + string[4294967295] runtime error: index out of range [4294967295] with length 3 + string[18446744073709551615] runtime error: index out of range [18446744073709551615] with length 3 + slice[0:0] no panic + slice[0:3] no panic + slice[0:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[0:4294967295] runtime error: slice bounds out of range [:4294967295] with capacity 3 + slice[0:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with capacity 3 + slice[3:0] runtime error: slice bounds out of range [3:0] + slice[3:3] no panic + slice[3:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[3:4294967295] runtime error: slice bounds out of range [:4294967295] with capacity 3 + slice[3:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with capacity 3 + slice[4:0] runtime error: slice bounds out of range [4:0] + slice[4:3] runtime error: slice bounds out of range [4:3] + slice[4:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[4:4294967295] runtime error: slice bounds out of range [:4294967295] with capacity 3 + slice[4:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with capacity 3 + slice[4294967295:0] runtime error: slice bounds out of range [4294967295:0] + slice[4294967295:3] runtime error: slice bounds out of range [4294967295:3] + slice[4294967295:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[4294967295:4294967295] runtime error: slice bounds out of range [:4294967295] with capacity 3 + slice[4294967295:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with capacity 3 + slice[18446744073709551615:0] runtime error: slice bounds out of range [18446744073709551615:0] + slice[18446744073709551615:3] runtime error: slice bounds out of range [18446744073709551615:3] + slice[18446744073709551615:4] runtime error: slice bounds out of range [:4] with capacity 3 + slice[18446744073709551615:4294967295] runtime error: slice bounds out of range [:4294967295] with capacity 3 + slice[18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with capacity 3 + array[0:0] no panic + array[0:3] no panic + array[0:4] runtime error: slice bounds out of range [:4] with length 3 + array[0:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + array[0:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + array[3:0] runtime error: slice bounds out of range [3:0] + array[3:3] no panic + array[3:4] runtime error: slice bounds out of range [:4] with length 3 + array[3:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + array[3:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + array[4:0] runtime error: slice bounds out of range [4:0] + array[4:3] runtime error: slice bounds out of range [4:3] + array[4:4] runtime error: slice bounds out of range [:4] with length 3 + array[4:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + array[4:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + array[4294967295:0] runtime error: slice bounds out of range [4294967295:0] + array[4294967295:3] runtime error: slice bounds out of range [4294967295:3] + array[4294967295:4] runtime error: slice bounds out of range [:4] with length 3 + array[4294967295:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + array[4294967295:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + array[18446744073709551615:0] runtime error: slice bounds out of range [18446744073709551615:0] + array[18446744073709551615:3] runtime error: slice bounds out of range [18446744073709551615:3] + array[18446744073709551615:4] runtime error: slice bounds out of range [:4] with length 3 + array[18446744073709551615:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + array[18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + string[0:0] no panic + string[0:3] no panic + string[0:4] runtime error: slice bounds out of range [:4] with length 3 + string[0:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + string[0:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + string[3:0] runtime error: slice bounds out of range [3:0] + string[3:3] no panic + string[3:4] runtime error: slice bounds out of range [:4] with length 3 + string[3:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + string[3:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + string[4:0] runtime error: slice bounds out of range [4:0] + string[4:3] runtime error: slice bounds out of range [4:3] + string[4:4] runtime error: slice bounds out of range [:4] with length 3 + string[4:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + string[4:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + string[4294967295:0] runtime error: slice bounds out of range [4294967295:0] + string[4294967295:3] runtime error: slice bounds out of range [4294967295:3] + string[4294967295:4] runtime error: slice bounds out of range [:4] with length 3 + string[4294967295:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + string[4294967295:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + string[18446744073709551615:0] runtime error: slice bounds out of range [18446744073709551615:0] + string[18446744073709551615:3] runtime error: slice bounds out of range [18446744073709551615:3] + string[18446744073709551615:4] runtime error: slice bounds out of range [:4] with length 3 + string[18446744073709551615:4294967295] runtime error: slice bounds out of range [:4294967295] with length 3 + string[18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [:18446744073709551615] with length 3 + slice[0:0:0] no panic + slice[0:0:3] no panic + slice[0:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:0:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[0:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[0:3:0] runtime error: slice bounds out of range [:3:0] + slice[0:3:3] no panic + slice[0:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:3:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[0:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[0:4:0] runtime error: slice bounds out of range [:4:0] + slice[0:4:3] runtime error: slice bounds out of range [:4:3] + slice[0:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:4:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[0:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[0:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + slice[0:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + slice[0:4294967295:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[0:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[0:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + slice[0:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + slice[0:18446744073709551615:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[0:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[0:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[3:0:0] runtime error: slice bounds out of range [3:0:] + slice[3:0:3] runtime error: slice bounds out of range [3:0:] + slice[3:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:0:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[3:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[3:3:0] runtime error: slice bounds out of range [:3:0] + slice[3:3:3] no panic + slice[3:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:3:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[3:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[3:4:0] runtime error: slice bounds out of range [:4:0] + slice[3:4:3] runtime error: slice bounds out of range [:4:3] + slice[3:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:4:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[3:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[3:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + slice[3:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + slice[3:4294967295:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[3:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[3:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + slice[3:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + slice[3:18446744073709551615:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[3:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[3:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4:0:0] runtime error: slice bounds out of range [4:0:] + slice[4:0:3] runtime error: slice bounds out of range [4:0:] + slice[4:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:0:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4:3:0] runtime error: slice bounds out of range [:3:0] + slice[4:3:3] runtime error: slice bounds out of range [4:3:] + slice[4:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:3:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4:4:0] runtime error: slice bounds out of range [:4:0] + slice[4:4:3] runtime error: slice bounds out of range [:4:3] + slice[4:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:4:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + slice[4:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + slice[4:4294967295:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + slice[4:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + slice[4:18446744073709551615:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4294967295:0:0] runtime error: slice bounds out of range [4294967295:0:] + slice[4294967295:0:3] runtime error: slice bounds out of range [4294967295:0:] + slice[4294967295:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4294967295:0:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4294967295:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4294967295:3:0] runtime error: slice bounds out of range [:3:0] + slice[4294967295:3:3] runtime error: slice bounds out of range [4294967295:3:] + slice[4294967295:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4294967295:3:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4294967295:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4294967295:4:0] runtime error: slice bounds out of range [:4:0] + slice[4294967295:4:3] runtime error: slice bounds out of range [:4:3] + slice[4294967295:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4294967295:4:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4294967295:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4294967295:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + slice[4294967295:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + slice[4294967295:4294967295:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4294967295:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4294967295:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[4294967295:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + slice[4294967295:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + slice[4294967295:18446744073709551615:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[4294967295:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[4294967295:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[18446744073709551615:0:0] runtime error: slice bounds out of range [18446744073709551615:0:] + slice[18446744073709551615:0:3] runtime error: slice bounds out of range [18446744073709551615:0:] + slice[18446744073709551615:0:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[18446744073709551615:0:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[18446744073709551615:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[18446744073709551615:3:0] runtime error: slice bounds out of range [:3:0] + slice[18446744073709551615:3:3] runtime error: slice bounds out of range [18446744073709551615:3:] + slice[18446744073709551615:3:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[18446744073709551615:3:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[18446744073709551615:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[18446744073709551615:4:0] runtime error: slice bounds out of range [:4:0] + slice[18446744073709551615:4:3] runtime error: slice bounds out of range [:4:3] + slice[18446744073709551615:4:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[18446744073709551615:4:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[18446744073709551615:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[18446744073709551615:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + slice[18446744073709551615:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + slice[18446744073709551615:4294967295:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[18446744073709551615:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[18446744073709551615:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + slice[18446744073709551615:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + slice[18446744073709551615:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + slice[18446744073709551615:18446744073709551615:4] runtime error: slice bounds out of range [::4] with capacity 3 + slice[18446744073709551615:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with capacity 3 + slice[18446744073709551615:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with capacity 3 + array[0:0:0] no panic + array[0:0:3] no panic + array[0:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:0:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[0:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[0:3:0] runtime error: slice bounds out of range [:3:0] + array[0:3:3] no panic + array[0:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:3:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[0:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[0:4:0] runtime error: slice bounds out of range [:4:0] + array[0:4:3] runtime error: slice bounds out of range [:4:3] + array[0:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:4:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[0:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[0:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + array[0:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + array[0:4294967295:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[0:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[0:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + array[0:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + array[0:18446744073709551615:4] runtime error: slice bounds out of range [::4] with length 3 + array[0:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[0:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[3:0:0] runtime error: slice bounds out of range [3:0:] + array[3:0:3] runtime error: slice bounds out of range [3:0:] + array[3:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:0:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[3:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[3:3:0] runtime error: slice bounds out of range [:3:0] + array[3:3:3] no panic + array[3:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:3:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[3:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[3:4:0] runtime error: slice bounds out of range [:4:0] + array[3:4:3] runtime error: slice bounds out of range [:4:3] + array[3:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:4:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[3:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[3:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + array[3:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + array[3:4294967295:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[3:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[3:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + array[3:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + array[3:18446744073709551615:4] runtime error: slice bounds out of range [::4] with length 3 + array[3:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[3:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4:0:0] runtime error: slice bounds out of range [4:0:] + array[4:0:3] runtime error: slice bounds out of range [4:0:] + array[4:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:0:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4:3:0] runtime error: slice bounds out of range [:3:0] + array[4:3:3] runtime error: slice bounds out of range [4:3:] + array[4:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:3:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4:4:0] runtime error: slice bounds out of range [:4:0] + array[4:4:3] runtime error: slice bounds out of range [:4:3] + array[4:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:4:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + array[4:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + array[4:4294967295:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + array[4:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + array[4:18446744073709551615:4] runtime error: slice bounds out of range [::4] with length 3 + array[4:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4294967295:0:0] runtime error: slice bounds out of range [4294967295:0:] + array[4294967295:0:3] runtime error: slice bounds out of range [4294967295:0:] + array[4294967295:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[4294967295:0:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4294967295:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4294967295:3:0] runtime error: slice bounds out of range [:3:0] + array[4294967295:3:3] runtime error: slice bounds out of range [4294967295:3:] + array[4294967295:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[4294967295:3:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4294967295:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4294967295:4:0] runtime error: slice bounds out of range [:4:0] + array[4294967295:4:3] runtime error: slice bounds out of range [:4:3] + array[4294967295:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[4294967295:4:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4294967295:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4294967295:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + array[4294967295:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + array[4294967295:4294967295:4] runtime error: slice bounds out of range [::4] with length 3 + array[4294967295:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4294967295:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[4294967295:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + array[4294967295:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + array[4294967295:18446744073709551615:4] runtime error: slice bounds out of range [::4] with length 3 + array[4294967295:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[4294967295:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[18446744073709551615:0:0] runtime error: slice bounds out of range [18446744073709551615:0:] + array[18446744073709551615:0:3] runtime error: slice bounds out of range [18446744073709551615:0:] + array[18446744073709551615:0:4] runtime error: slice bounds out of range [::4] with length 3 + array[18446744073709551615:0:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[18446744073709551615:0:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[18446744073709551615:3:0] runtime error: slice bounds out of range [:3:0] + array[18446744073709551615:3:3] runtime error: slice bounds out of range [18446744073709551615:3:] + array[18446744073709551615:3:4] runtime error: slice bounds out of range [::4] with length 3 + array[18446744073709551615:3:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[18446744073709551615:3:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[18446744073709551615:4:0] runtime error: slice bounds out of range [:4:0] + array[18446744073709551615:4:3] runtime error: slice bounds out of range [:4:3] + array[18446744073709551615:4:4] runtime error: slice bounds out of range [::4] with length 3 + array[18446744073709551615:4:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[18446744073709551615:4:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[18446744073709551615:4294967295:0] runtime error: slice bounds out of range [:4294967295:0] + array[18446744073709551615:4294967295:3] runtime error: slice bounds out of range [:4294967295:3] + array[18446744073709551615:4294967295:4] runtime error: slice bounds out of range [::4] with length 3 + array[18446744073709551615:4294967295:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[18446744073709551615:4294967295:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 + array[18446744073709551615:18446744073709551615:0] runtime error: slice bounds out of range [:18446744073709551615:0] + array[18446744073709551615:18446744073709551615:3] runtime error: slice bounds out of range [:18446744073709551615:3] + array[18446744073709551615:18446744073709551615:4] runtime error: slice bounds out of range [::4] with length 3 + array[18446744073709551615:18446744073709551615:4294967295] runtime error: slice bounds out of range [::4294967295] with length 3 + array[18446744073709551615:18446744073709551615:18446744073709551615] runtime error: slice bounds out of range [::18446744073709551615] with length 3 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30243.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30243.go new file mode 100644 index 0000000000000000000000000000000000000000..51fd204cbc6decb3690f0a940c2b369c3f83bd27 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30243.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2019 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. + +// Compile-time constants, even if they cannot be represented +// accurately, should remain the same in operations that don't +// affect their values. + +package main + +import "fmt" + +func main() { + const x = 0.01 + const xi = 0.01i + const xc = complex(0, x) + + if imag(xi) != x { + fmt.Printf("FAILED: %g != %g\n", imag(xi), x) + } + + if xi != complex(0, x) { + fmt.Printf("FAILED: %g != %g\n", xi, complex(0, x)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30430.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30430.go new file mode 100644 index 0000000000000000000000000000000000000000..6c27b82881a07ca218b60a88839dfc0a6dc7edcc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30430.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2019 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. + +// Issue 30430: isGoConst returned true for non-const variables, +// resulting in ICE. + +package p + +func f() { + var s string + _ = map[string]string{s: ""} +} + +const s = "" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30476.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30476.go new file mode 100644 index 0000000000000000000000000000000000000000..a2147ec0c1e608dac26de995988f37c5de3de0d9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30476.go @@ -0,0 +1,30 @@ +// run + +// Copyright 2019 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. + +// Issue 30476: KeepAlive didn't keep stack object alive. + +package main + +import "runtime" + +func main() { + x := new([10]int) + runtime.SetFinalizer(x, func(*[10]int) { panic("FAIL: finalizer runs") }) + p := &T{x, 0} + use(p) + runtime.GC() + runtime.GC() + runtime.GC() + runtime.KeepAlive(p) +} + +type T struct { + x *[10]int + y int +} + +//go:noinline +func use(*T) {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30566a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30566a.go new file mode 100644 index 0000000000000000000000000000000000000000..5d736ccd0dc44587c5dac72a156560e495c475cb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30566a.go @@ -0,0 +1,23 @@ +// run + +// Copyright 2019 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 + +import "fmt" + +//go:noinline +func ident(s string) string { return s } + +func returnSecond(x bool, s string) string { return s } + +func identWrapper(s string) string { return ident(s) } + +func main() { + got := returnSecond((false || identWrapper("bad") != ""), ident("good")) + if got != "good" { + panic(fmt.Sprintf("wanted \"good\", got \"%s\"", got)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30566b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30566b.go new file mode 100644 index 0000000000000000000000000000000000000000..92e064436dd83ae7468ee9ac76d9a32efe017511 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30566b.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2019 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 + +import ( + "bytes" + "fmt" +) + +func main() { + _, _ = false || g(1), g(2) + if !bytes.Equal(x, []byte{1, 2}) { + panic(fmt.Sprintf("wanted [1,2], got %v", x)) + } +} + +var x []byte + +//go:noinline +func g(b byte) bool { + x = append(x, b) + return false +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30606.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30606.go new file mode 100644 index 0000000000000000000000000000000000000000..bc31982e10f5e5e17d94cff12a48d22100a1b8f4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30606.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2019 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 + +import "reflect" + +func main() {} + +func typ(x interface{}) reflect.Type { return reflect.ValueOf(x).Type() } + +var x = reflect.New(reflect.StructOf([]reflect.StructField{ + {Name: "F5", Type: reflect.StructOf([]reflect.StructField{ + {Name: "F4", Type: reflect.ArrayOf(5462, + reflect.SliceOf(typ(uint64(0))))}, + })}, +})) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30606b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30606b.go new file mode 100644 index 0000000000000000000000000000000000000000..2ce2804ad8dafd7f0a823dd0ea19e263b35d6547 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30606b.go @@ -0,0 +1,51 @@ +// run + +// Copyright 2019 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 + +import "reflect" + +func main() {} + +func typ(x interface{}) reflect.Type { return reflect.ValueOf(x).Type() } + +var byteType = typ((byte)(0)) +var ptrType = typ((*byte)(nil)) + +// Arrays of pointers. There are two size thresholds. +// Bit masks are chunked in groups of 120 pointers. +// Array types with >16384 pointers have a GC program instead of a bitmask. +var smallPtrType = reflect.ArrayOf(100, ptrType) +var mediumPtrType = reflect.ArrayOf(1000, ptrType) +var bigPtrType = reflect.ArrayOf(16385, ptrType) + +var x0 = reflect.New(reflect.StructOf([]reflect.StructField{ + {Name: "F1", Type: byteType}, + {Name: "F2", Type: bigPtrType}, +})) +var x1 = reflect.New(reflect.StructOf([]reflect.StructField{ + {Name: "F1", Type: smallPtrType}, + {Name: "F2", Type: bigPtrType}, +})) +var x2 = reflect.New(reflect.StructOf([]reflect.StructField{ + {Name: "F1", Type: mediumPtrType}, + {Name: "F2", Type: bigPtrType}, +})) +var x3 = reflect.New(reflect.StructOf([]reflect.StructField{ + {Name: "F1", Type: ptrType}, + {Name: "F2", Type: byteType}, + {Name: "F3", Type: bigPtrType}, +})) +var x4 = reflect.New(reflect.StructOf([]reflect.StructField{ + {Name: "F1", Type: ptrType}, + {Name: "F2", Type: smallPtrType}, + {Name: "F3", Type: bigPtrType}, +})) +var x5 = reflect.New(reflect.StructOf([]reflect.StructField{ + {Name: "F1", Type: ptrType}, + {Name: "F2", Type: mediumPtrType}, + {Name: "F3", Type: bigPtrType}, +})) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30659.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30659.go new file mode 100644 index 0000000000000000000000000000000000000000..973ae1dcef229fff93cfeb070dc2b64f1ccfd0e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30659.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30679.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30679.go new file mode 100644 index 0000000000000000000000000000000000000000..4d0df18f45faf5e7a0d7d392ed96da5d7ec49631 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30679.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2019 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 main() { + var f float64 + var p, q *float64 + + p = &f + if *q > 0 { + p = q + } + _ = *p +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30709.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30709.go new file mode 100644 index 0000000000000000000000000000000000000000..49524540ed31e30a6376a3a26107cb5b97a5fbbf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30709.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2019 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. + +// Check closure in const declaration group can be compiled +// and set correct value + +package main + +import "unsafe" + +const ( + x = unsafe.Sizeof(func() {}) + y +) + +func main() { + const ( + z = unsafe.Sizeof(func() {}) + t + ) + + // x and y must be equal + println(x == y) + // size must be greater than zero + println(y > 0) + + // Same logic as x, y above + println(z == t) + println(t > 0) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30709.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue30709.out new file mode 100644 index 0000000000000000000000000000000000000000..1140ff52e2ba1f46b1315269500c551a9bd48768 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30709.out @@ -0,0 +1,4 @@ +true +true +true +true diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30722.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30722.go new file mode 100644 index 0000000000000000000000000000000000000000..fe04c8f41a0c31e3cd9629a6da787eb664009ab5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30722.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2019 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. + +// Verify that we only get one error per invalid integer literal. + +package p + +const ( + _ = 1_ // ERROR "'_' must separate successive digits" + _ = 0b // ERROR "binary literal has no digits|invalid numeric literal" + _ = 0o // ERROR "octal literal has no digits|invalid numeric literal" + _ = 0x // ERROR "hexadecimal literal has no digits|invalid numeric literal" + _ = 0xde__ad // ERROR "'_' must separate successive digits" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30862.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30862.go new file mode 100644 index 0000000000000000000000000000000000000000..acac71e2ccabd4d85c16b9e38265f93f03af0652 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30862.go @@ -0,0 +1,12 @@ +// runindir -goexperiment fieldtrack + +// Copyright 2019 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. + +// Test case for issue 30862. This test as written will +// fail for the main 'gc' compiler unless GOEXPERIMENT=fieldtrack +// is set when building it, whereas gccgo has field tracking +// enabled by default (hence the build tag below). + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30898.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30898.go new file mode 100644 index 0000000000000000000000000000000000000000..c7f6f2d3712b3cf507cbc8d1338a4604d99e5c47 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30898.go @@ -0,0 +1,19 @@ +// errorcheck -0 -m + +// Copyright 2019 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. + +// Test escape analysis for functions with variadic arguments + +package foo + +func debugf(format string, args ...interface{}) { // ERROR "can inline debugf" "format does not escape" "args does not escape" + // Dummy implementation for non-debug build. + // A non-empty implementation would be enabled with a build tag. +} + +func bar() { // ERROR "can inline bar" + value := 10 + debugf("value is %d", value) // ERROR "inlining call to debugf" "value does not escape" "\.\.\. argument does not escape" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30907.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30907.go new file mode 100644 index 0000000000000000000000000000000000000000..973ae1dcef229fff93cfeb070dc2b64f1ccfd0e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30907.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30908.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30908.go new file mode 100644 index 0000000000000000000000000000000000000000..98dd641066fc6ea07b50dc6db8012377c12763ba --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30908.go @@ -0,0 +1,9 @@ +// rundir -ldflags -strictdups=2 -w=0 + +// Copyright 2019 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. + +//go:build !nacl && !js + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30956.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30956.go new file mode 100644 index 0000000000000000000000000000000000000000..021e6c5d47bbdec4ea666f984041e0536f43c503 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30956.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2019 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. + +// Check for compile generated static data for literal +// composite struct + +package main + +import "fmt" + +type X struct { + V interface{} + + a int + b int + c int +} + +func pr(x X) { + fmt.Println(x.V) +} + +func main() { + pr(X{ + V: struct { + A int + }{42}, + }) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30956.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue30956.out new file mode 100644 index 0000000000000000000000000000000000000000..04f25e8ae79c03312a173a68cab043cd42e2dd28 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30956.out @@ -0,0 +1 @@ +{42} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue30977.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue30977.go new file mode 100644 index 0000000000000000000000000000000000000000..2ca040d79a1c78ffb69245275c6bdd881efb59e6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue30977.go @@ -0,0 +1,52 @@ +// run + +// Copyright 2019 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. + +// Issue 30977: write barrier call clobbers volatile +// value when there are multiple uses of the value. + +package main + +import "runtime" + +type T struct { + a, b, c, d, e string +} + +//go:noinline +func g() T { + return T{"a", "b", "c", "d", "e"} +} + +//go:noinline +func f() { + // The compiler optimizes this to direct copying + // the call result to both globals, with write + // barriers. The first write barrier call clobbers + // the result of g on stack. + X = g() + Y = X +} + +var X, Y T + +const N = 1000 + +func main() { + // Keep GC running so the write barrier is on. + go func() { + for { + runtime.GC() + } + }() + + for i := 0; i < N; i++ { + runtime.Gosched() + f() + if X != Y { + panic("FAIL") + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31010.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31010.go new file mode 100644 index 0000000000000000000000000000000000000000..836e85fd12321b8a42ac62b53540f7dbf346e663 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31010.go @@ -0,0 +1,24 @@ +// compile + +// Copyright 2019 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 p + +var ( + x int + xs []int +) + +func a([]int) (int, error) + +func b() (int, error) { + return a(append(xs, x)) +} + +func c(int, error) (int, error) + +func d() (int, error) { + return c(b()) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31053.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31053.go new file mode 100644 index 0000000000000000000000000000000000000000..a33d3ff3474725a328007c38643d2f9b0e3a68f0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31053.go @@ -0,0 +1,7 @@ +// errorcheckdir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31060.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31060.go new file mode 100644 index 0000000000000000000000000000000000000000..a1ba705160a2d9db7615d86d828eecd01d22190b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31060.go @@ -0,0 +1,30 @@ +// errorcheck + +// Copyright 2019 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 p + +const ( + f = 1.0 + c = 1.0i + + _ = ^f // ERROR "invalid operation|expected integer" + _ = ^c // ERROR "invalid operation|expected integer" + + _ = f % f // ERROR "invalid operation|expected integer" + _ = c % c // ERROR "invalid operation|expected integer" + + _ = f & f // ERROR "invalid operation|expected integer" + _ = c & c // ERROR "invalid operation|expected integer" + + _ = f | f // ERROR "invalid operation|expected integer" + _ = c | c // ERROR "invalid operation|expected integer" + + _ = f ^ f // ERROR "invalid operation|expected integer" + _ = c ^ c // ERROR "invalid operation|expected integer" + + _ = f &^ f // ERROR "invalid operation|expected integer" + _ = c &^ c // ERROR "invalid operation|expected integer" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31252.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31252.go new file mode 100644 index 0000000000000000000000000000000000000000..973ae1dcef229fff93cfeb070dc2b64f1ccfd0e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31252.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31412a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31412a.go new file mode 100644 index 0000000000000000000000000000000000000000..75021c68d268a4ac3693d6ddc3e0bc5e77d16868 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31412a.go @@ -0,0 +1,32 @@ +// compile + +// Copyright 2019 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. + +// This code was incorrectly flagged as erroneous by gccgo. + +package main + +type Name string + +type EFunc func(int) int + +func Register(f EFunc, names ...Name) int { + return f(len(names)) +} + +const ( + B Name = "B" +) + +func RegisterIt() { + n := B + "Duck" + d := B + "Goose" + f := func(x int) int { return x + 9 } + Register(f, n, d) +} + +func main() { + RegisterIt() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31412b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31412b.go new file mode 100644 index 0000000000000000000000000000000000000000..6c4ec00dc9bc74ec86b718d1b2bff6df86be4b62 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31412b.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2019 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. + +// This code was incorrectly accepted by gccgo. + +package main + +type N string +type M string + +const B N = "B" +const C M = "C" + +func main() { + q := B + C // ERROR "mismatched types|incompatible types" + println(q) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31419.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31419.go new file mode 100644 index 0000000000000000000000000000000000000000..233111ae14869e15468073c7d690528d93e0aa0a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31419.go @@ -0,0 +1,58 @@ +// run + +// Copyright 2019 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. + +// Issue 31419: race in getitab when two goroutines try +// to do the same failed interface conversion. + +package main + +type T int + +func (t T) M() {} + +type I interface { + M() + M2() +} + +var t T +var e interface{} = &t +var ok = false +var ch = make(chan int) + +func main() { + _, ok = e.(I) // populate itab cache with a false result + + go f() // get itab in a loop + + var i I + for k := 0; k < 10000; k++ { + i, ok = e.(I) // read the cached itab + if ok { + println("iteration", k, "i =", i, "&t =", &t) + panic("conversion succeeded") + } + } + <-ch +} + +func f() { + for i := 0; i < 10000; i++ { + f1() + } + ch <- 1 +} + +func f1() { + defer func() { + err := recover() + if err == nil { + panic("did not panic") + } + }() + i := e.(I) // triggers itab.init, for getting the panic string + _ = i +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31546.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31546.go new file mode 100644 index 0000000000000000000000000000000000000000..a459d4d124494055f97632ce5e777e7af8a5e016 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31546.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2019 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 + +import ( + "reflect" +) + +var x = struct{ a, _, c int }{1, 2, 3} + +func main() { + if i := reflect.ValueOf(x).Field(1).Int(); i != 0 { + println("got", i, "want", 0) + panic("fail") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31573.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31573.go new file mode 100644 index 0000000000000000000000000000000000000000..5197163f04f0a99ea5227740d778147da3315373 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31573.go @@ -0,0 +1,49 @@ +// errorcheck -0 -m -l + +// Copyright 2019 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 p + +func f(...*int) {} + +func g() { + defer f() + defer f(new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + defer f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + + defer f(nil...) + defer f([]*int{}...) // ERROR "\[\]\*int{} does not escape$" + defer f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + defer f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + + go f() + go f(new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + + go f(nil...) + go f([]*int{}...) // ERROR "\[\]\*int{} does not escape$" + go f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + + for { + defer f() + defer f(new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + defer f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + + defer f(nil...) + defer f([]*int{}...) // ERROR "\[\]\*int{} does not escape$" + defer f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + defer f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + + go f() + go f(new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + go f(new(int), new(int)) // ERROR "... argument does not escape$" "new\(int\) does not escape$" + + go f(nil...) + go f([]*int{}...) // ERROR "\[\]\*int{} does not escape$" + go f([]*int{new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + go f([]*int{new(int), new(int)}...) // ERROR "\[\]\*int{...} does not escape$" "new\(int\) does not escape$" + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31636.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31636.go new file mode 100644 index 0000000000000000000000000000000000000000..af6f1341729458e04aba9a8a7110ec999540bc2a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31636.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31636.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue31636.out new file mode 100644 index 0000000000000000000000000000000000000000..de980441c3ab03a8c07dda1ad27b8a11f39deb1e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31636.out @@ -0,0 +1,3 @@ +a +b +c diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31637.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31637.go new file mode 100644 index 0000000000000000000000000000000000000000..dcfb4a7e53d19e1840c9b944c50ebce9458c5e71 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31637.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2019 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. + +// This directory contains a pair of packages that triggered +// a compiler crash in gollvm (problem in handling an inlinable +// method with unnamed parameter). See issue 31637 for details. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31747.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31747.go new file mode 100644 index 0000000000000000000000000000000000000000..319a721337efc6ae470c5e77401456c1d266b342 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31747.go @@ -0,0 +1,34 @@ +// errorcheck -lang=go1.12 + +// Copyright 2019 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 p + +// numeric literals +const ( + _ = 1_000 // ERROR "underscores in numeric literals requires go1.13 or later \(-lang was set to go1.12; check go.mod\)|requires go1.13" + _ = 0b111 // ERROR "binary literals requires go1.13 or later" + _ = 0o567 // ERROR "0o/0O-style octal literals requires go1.13 or later" + _ = 0xabc // ok + _ = 0x0p1 // ERROR "hexadecimal floating-point literals requires go1.13 or later" + + _ = 0B111 // ERROR "binary" + _ = 0O567 // ERROR "octal" + _ = 0Xabc // ok + _ = 0X0P1 // ERROR "hexadecimal floating-point" + + _ = 1_000i // ERROR "underscores" + _ = 0b111i // ERROR "binary" + _ = 0o567i // ERROR "octal" + _ = 0xabci // ERROR "hexadecimal floating-point" + _ = 0x0p1i // ERROR "hexadecimal floating-point" +) + +// signed shift counts +var ( + s int + _ = 1 << s // ERROR "invalid operation: 1 << s \(signed shift count type int\) requires go1.13 or later|signed shift count" + _ = 1 >> s // ERROR "signed shift count" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31777.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31777.go new file mode 100644 index 0000000000000000000000000000000000000000..839e242c95cdb299ed53f419d54f52c6141c6016 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31777.go @@ -0,0 +1,24 @@ +// compile + +// Copyright 2019 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. + +// Compile with static map literal. + +package p + +type i interface { + j() +} + +type s struct{} + +func (s) j() {} + +type foo map[string]i + +var f = foo{ + "1": s{}, + "2": s{}, +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31782.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31782.go new file mode 100644 index 0000000000000000000000000000000000000000..a42001ea0ea1aa8cb473fa7a1dcc887e452ceb82 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31782.go @@ -0,0 +1,24 @@ +// run + +// Copyright 2019 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. + +// Check static composite literal reports wrong for struct +// field. + +package main + +type one struct { + i interface{} +} + +type two struct { + i interface{} + s []string +} + +func main() { + o := one{i: two{i: 42}.i} + println(o.i.(int)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31782.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue31782.out new file mode 100644 index 0000000000000000000000000000000000000000..d81cc0710eb6cf9efd5b920a8453e1e07157b6cd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31782.out @@ -0,0 +1 @@ +42 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31915.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31915.go new file mode 100644 index 0000000000000000000000000000000000000000..96af175e23d4e6869d173f4f3ff303ad8e493594 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31915.go @@ -0,0 +1,23 @@ +// compile -d=ssa/check/on + +// Copyright 2019 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 p + +func f() + +func g() { + var a []int + var b bool + for { + b = (b && b) != (b && b) + for b && b == b || true { + f() + _ = a[0] + } + _ = &b + a = []int{} + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31959.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31959.go new file mode 100644 index 0000000000000000000000000000000000000000..af6f1341729458e04aba9a8a7110ec999540bc2a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31959.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31959.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue31959.out new file mode 100644 index 0000000000000000000000000000000000000000..8ddcb67af1c72e24830400f3fd4b764a1898d416 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31959.out @@ -0,0 +1,2 @@ +{} +0 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue31987.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue31987.go new file mode 100644 index 0000000000000000000000000000000000000000..372289b52d3689db918d3de94f6cea522831caab --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue31987.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2019 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 + +import "fmt" + +type container struct { + Value string +} + +func main() { + s := []container{ + 7: {Value: "string value"}, + } + if s[7].Value != "string value" { + panic(fmt.Errorf("wanted \"string value\", got \"%s\"", s[7].Value)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32133.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32133.go new file mode 100644 index 0000000000000000000000000000000000000000..f3cca87a72ea7c7e1cb2fe0aeac23cf043bccbef --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32133.go @@ -0,0 +1,43 @@ +// errorcheck + +// Copyright 2019 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 p + +// errors for the //line-adjusted code below +// ERROR "newline in string" +// ERROR "newline in character literal|newline in rune literal" +// ERROR "newline in string" +// ERROR "string not terminated" + +//line :10:1 +import "foo + +//line :19:1 +func _() { + 0x // ERROR "hexadecimal literal has no digits" +} + +func _() { + 0x1.0 // ERROR "hexadecimal mantissa requires a 'p' exponent" +} + +func _() { + 0_i // ERROR "'_' must separate successive digits" +} + +func _() { +//line :11:1 + ' +} + +func _() { +//line :12:1 + " +} + +func _() { +//line :13:1 + ` \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32175.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32175.go new file mode 100644 index 0000000000000000000000000000000000000000..a67735148e2b084b7e7a7cda1e2dc6e5ad19e827 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32175.go @@ -0,0 +1,22 @@ +// run + +// Copyright 2019 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 + +// This used to print 0, because x was incorrectly captured by value. + +func f() (x int) { + defer func() func() { + return func() { + println(x) + } + }()() + return 42 +} + +func main() { + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32175.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue32175.out new file mode 100644 index 0000000000000000000000000000000000000000..d81cc0710eb6cf9efd5b920a8453e1e07157b6cd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32175.out @@ -0,0 +1 @@ +42 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32187.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32187.go new file mode 100644 index 0000000000000000000000000000000000000000..268da8112ff8f2808f3e11089009feae8c83695d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32187.go @@ -0,0 +1,62 @@ +// run + +// Copyright 2019 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. + +// short-circuiting interface-to-concrete comparisons +// will not miss panics + +package main + +import ( + "log" + "strings" +) + +func main() { + var ( + x interface{} + p *int + s []int + l *interface{} + r []*int + ) + tests := []struct { + name string + errStr string + f func() + }{ + {"switch case", "", func() { + switch x { + case x.(*int): + } + }}, + {"interface conversion", "", func() { _ = x == x.(error) }}, + {"type assertion", "", func() { _ = x == x.(*int) }}, + {"out of bounds", "", func() { _ = x == s[1] }}, + {"nil pointer dereference #1", "", func() { _ = x == *p }}, + // TODO(mdempsky): Restore "nil pointer dereference" check. The Go + // spec doesn't mandate an order for panics (or even panic + // messages), but left-to-right is less confusing to users. + {"nil pointer dereference #2", "", func() { _ = *l == r[0] }}, + {"nil pointer dereference #3", "", func() { _ = *l == any(r[0]) }}, + } + + for _, tc := range tests { + testFuncShouldPanic(tc.name, tc.errStr, tc.f) + } +} + +func testFuncShouldPanic(name, want string, f func()) { + defer func() { + e := recover() + if e == nil { + log.Fatalf("%s: comparison did not panic\n", name) + } + if have := e.(error).Error(); !strings.Contains(have, want) { + log.Fatalf("%s: wrong panic message: have %q, want %q\n", name, have, want) + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32288.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32288.go new file mode 100644 index 0000000000000000000000000000000000000000..91c930c0b506bca704a30b9ad15bb1d6722cbac4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32288.go @@ -0,0 +1,48 @@ +// run + +// Copyright 2019 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 + +type T struct { + s [1]string + pad [16]uintptr +} + +//go:noinline +func f(t *int, p *int) []T { + var res []T + for { + var e *T + res = append(res, *e) + } +} + +func main() { + defer func() { + useStack(100) // force a stack copy + // We're expecting a panic. + // The bug in this issue causes a throw, which this recover() will not squash. + recover() + }() + junk() // fill the stack with invalid pointers + f(nil, nil) +} + +func useStack(n int) { + if n == 0 { + return + } + useStack(n - 1) +} + +//go:noinline +func junk() uintptr { + var a [128]uintptr // 1k of bad pointers on the stack + for i := range a { + a[i] = 0xaa + } + return a[12] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32347.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32347.go new file mode 100644 index 0000000000000000000000000000000000000000..91c038a588fd34916df25bf55ad01e44a0b834cf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32347.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2019 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. + +// Issue 32347: gccgo compiler crashes with int-to-string conversion +// with large integer constant operand. + +package p + +const ( + X1 = string(128049) + X2 = string(-1) + X3 = string(1<<48) +) + +var S1, S2, S3 = X1, X2, X3 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32454.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32454.go new file mode 100644 index 0000000000000000000000000000000000000000..70895c97fa4cb7074e0efbd65b2e0d94de785b5c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32454.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2019 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 p + +type T struct { + s string + f float64 +} + +func f() { + var f float64 + var st T + for { + switch &st.f { + case &f: + f = 1 + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32477.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32477.go new file mode 100644 index 0000000000000000000000000000000000000000..8b3c17528985de89db7f3009d60261575580fbce --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32477.go @@ -0,0 +1,71 @@ +// run + +// Copyright 2019 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. + +// Make sure we use the deferreturn live map instead of +// the entry live map when handling a segv in a function +// that defers. + +package main + +import "runtime" + +var finalized bool +var err string + +type HeapObj [8]int64 + +const filler int64 = 0x123456789abcdef0 + +func (h *HeapObj) init() { + for i := 0; i < len(*h); i++ { + h[i] = filler + } +} +func (h *HeapObj) check() { + for i := 0; i < len(*h); i++ { + if h[i] != filler { + err = "filler overwritten" + } + } +} + +func gc(shouldFinalize bool) { + runtime.GC() + runtime.GC() + runtime.GC() + if shouldFinalize != finalized { + err = "heap object finalized at the wrong time" + } +} + +func main() { + h := new(HeapObj) + h.init() + runtime.SetFinalizer(h, func(h *HeapObj) { + finalized = true + }) + + gc(false) + g(h) + if err != "" { + panic(err) + } +} + +func g(h *HeapObj) { + gc(false) + h.check() + // h is now unused + defer func() { + // h should not be live here. Previously we used to + // use the function entry point as the place to get + // the live map when handling a segv. + gc(true) + recover() + }() + *(*int)(nil) = 0 // trigger a segv + return +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32560.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32560.go new file mode 100644 index 0000000000000000000000000000000000000000..c6f72b6b55062a4772201617ac70939a870299a8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32560.go @@ -0,0 +1,51 @@ +// run + +// Copyright 2019 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. + +// Values smaller than 64-bits were mistakenly always proven to be +// non-negative. +// +// The tests here are marked go:noinline to ensure they're +// independently optimized by SSA. + +package main + +var x int32 = -1 + +//go:noinline +func a() { + if x != -1 { + panic(1) + } + if x > 0 || x != -1 { + panic(2) + } +} + +//go:noinline +func b() { + if x != -1 { + panic(3) + } + if x > 0 { + panic(4) + } +} + +//go:noinline +func c() { + if x > 0 || x != -1 { + panic(5) + } + if x > 0 || x != -1 { + panic(6) + } +} + +func main() { + a() + b() + c() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32595.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32595.go new file mode 100644 index 0000000000000000000000000000000000000000..af6f1341729458e04aba9a8a7110ec999540bc2a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32595.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2019 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32680.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32680.go new file mode 100644 index 0000000000000000000000000000000000000000..27cba6bf78731a2c76be5bc9cb8aeecf7c737a6a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32680.go @@ -0,0 +1,23 @@ +// run -gcflags=-d=ssa/check/on + +// Copyright 2019 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. + +// As of 2019-06, bug affects/ed amd64 and s390x. + +package main + +var foo = []byte{105, 57, 172, 152} + +func main() { + for i := 0; i < len(foo); i += 4 { + // Requires inlining and non-constant i + // Note the bug/fix also apply to different widths, but was unable to reproduce for those. + println(readLittleEndian32_2(foo[i], foo[i+1], foo[i+2], foo[i+3])) + } +} + +func readLittleEndian32_2(a, b, c, d byte) uint32 { + return uint32(a) | (uint32(b) << 8) | (uint32(c) << 16) | (uint32(d) << 24) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32680.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue32680.out new file mode 100644 index 0000000000000000000000000000000000000000..4d60a97392c1affc1f82b199fe50ebbb266fedf9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32680.out @@ -0,0 +1 @@ +2561423721 diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32680b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32680b.go new file mode 100644 index 0000000000000000000000000000000000000000..09bc3a9ce036f6ccecd37b062839e6e91d2b734f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32680b.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2019 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 p + +func hashBytesRaw(b0, b1, b2, b3, b7 byte) uint64 { + return (uint64(b0) | uint64(b1)<<8 | uint64(b2)<<16 | uint64(b3)<<24) +} + +func doStuff(data []byte) uint64 { + return hashBytesRaw(data[0], data[1], data[2], data[3], data[7]) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32723.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32723.go new file mode 100644 index 0000000000000000000000000000000000000000..850334d7024ef454e90e3630e97baae5e4a8a0ec --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32723.go @@ -0,0 +1,22 @@ +// errorcheck + +// Copyright 2019 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. + +// Complex literal comparison + +package p + +const x = 1i +const y = 1i < 2i // ERROR "invalid operation: .*not defined on untyped complex|non-ordered type" +const z = x < 2i // ERROR "invalid operation: .*not defined on untyped complex|non-ordered type" + +func f() { + _ = 1i < 2i // ERROR "invalid operation: .*not defined on untyped complex|non-ordered type" + _ = 1i < 2 // ERROR "invalid operation: .*not defined on untyped complex|non-ordered type" + _ = 1 < 2i // ERROR "invalid operation: .*not defined on untyped complex|non-ordered type" + + c := 1i + _ = c < 2i // ERROR "invalid operation: .*not defined on complex128|non-ordered type" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32778.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32778.go new file mode 100644 index 0000000000000000000000000000000000000000..83456d4a999680844390bb040ab2986ce2e3ec78 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32778.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2019 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. + +// This directory contains a pair of packages that triggers a compiler +// crash in gccgo (problem with tracking indirectly referenced +// packages during exporting). See issue 32778 for details. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32901.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32901.go new file mode 100644 index 0000000000000000000000000000000000000000..004c3da79eef1f32151a0ef52607354d405a1ae5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32901.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2019 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. + +// Issue 32901: type descriptor equality bug in gccgo. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32922.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32922.go new file mode 100644 index 0000000000000000000000000000000000000000..005c8e68cb4615c09c7333ee8657dd44f2ce71e5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32922.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2019 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. + +// This directory contains a pair of packages that triggers a compiler +// error in gccgo (problem with the way inlinable call expressions are +// imported). See issue 32922 for details. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue32959.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue32959.go new file mode 100644 index 0000000000000000000000000000000000000000..a0dc789a0438a500cad8a227853daaaa46d5d929 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue32959.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2019 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. + +// Test escape analysis with shifting constant + +package main + +import "unsafe" + +func main() { + var l uint64 + var p unsafe.Pointer + _ = unsafe.Pointer(uintptr(p) + (uintptr(l) >> 1)) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33013.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33013.go new file mode 100644 index 0000000000000000000000000000000000000000..e363cf500f3fb4d8ff3343d2db84140785e275ff --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33013.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 33013: gccgo compiler error with inlinable function + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33020.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33020.go new file mode 100644 index 0000000000000000000000000000000000000000..ccdf1874537866826b2646ff78d20b6123b0b133 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33020.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 33020: gccgo undefined behavior with inlinable function + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33020a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33020a.go new file mode 100644 index 0000000000000000000000000000000000000000..cfe010e92f161640192c11f64c33e9c280cb5bbe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33020a.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 33020: gollvm assert in Llvm_backend::materializeComposite + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33062.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33062.go new file mode 100644 index 0000000000000000000000000000000000000000..5e6a3581a17c1e3f93de1238da9910c6c6ff4303 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33062.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2019 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. + +// Issue 33062: gccgo generates incorrect type equality +// functions. + +package main + +type simpleStruct struct { + int + string +} + +type complexStruct struct { + int + simpleStruct +} + +func main() { + x := complexStruct{1, simpleStruct{2, "xxx"}} + ix := interface{}(x) + y := complexStruct{1, simpleStruct{2, "yyy"}} + iy := interface{}(y) + if ix != ix { + panic("FAIL") + } + if ix == iy { + panic("FAIL") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33158.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33158.go new file mode 100644 index 0000000000000000000000000000000000000000..1bba8f2f76f55f2d2689ce019f1ce45d8309bf53 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33158.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 33158: gccgo duplicate def error from importing inlinable function + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33219.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33219.go new file mode 100644 index 0000000000000000000000000000000000000000..45edc8ba65f21c25d91e7f7c6f9e43f6ce851147 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33219.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 33219: gccgo assert in "implements_interface()" + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33275.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33275.go new file mode 100644 index 0000000000000000000000000000000000000000..f2ec24dbc28544fca53c6f120bdb23a27e2a1f97 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33275.go @@ -0,0 +1,34 @@ +// skip + +// Copyright 2019 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 + +import ( + "fmt" + "time" +) + +func main() { + // Make a big map. + m := map[int]int{} + for i := 0; i < 100000; i++ { + m[i] = i + } + c := make(chan string) + go func() { + // Print the map. + s := fmt.Sprintln(m) + c <- s + }() + go func() { + time.Sleep(1 * time.Millisecond) + // Add an extra item to the map while iterating. + m[-1] = -1 + c <- "" + }() + <-c + <-c +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33275_run.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33275_run.go new file mode 100644 index 0000000000000000000000000000000000000000..542cc03f60dcd00bdfc841a6f7412affd7a456c4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33275_run.go @@ -0,0 +1,26 @@ +// run + +//go:build !nacl && !js && !wasip1 && !gccgo + +// Copyright 2019 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. + +// Make sure we don't get an index out of bounds error +// while trying to print a map that is concurrently modified. +// The runtime might complain (throw) if it detects the modification, +// so we have to run the test as a subprocess. + +package main + +import ( + "os/exec" + "strings" +) + +func main() { + out, _ := exec.Command("go", "run", "fixedbugs/issue33275.go").CombinedOutput() + if strings.Contains(string(out), "index out of range") { + panic(`go run issue33275.go reported "index out of range"`) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33308.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33308.go new file mode 100644 index 0000000000000000000000000000000000000000..5821099e3d36599e3944e2cce841709b0bdc8403 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33308.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2020 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. + +// Test that the compiler does not crash on a []byte conversion of an +// untyped expression. +package p + +var v uint +var x = []byte((1 << v) + 1) // ERROR "cannot convert|non-integer type for left operand of shift" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33355.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33355.go new file mode 100644 index 0000000000000000000000000000000000000000..c4b1e2e1a23ba42c13c28e2e286f8ed113a3414c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33355.go @@ -0,0 +1,147 @@ +// compile + +// Copyright 2019 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. + +// This code failed on arm64 in the register allocator. +// See issue 33355. + +package server + +import ( + "bytes" + "sync" +) + +type client struct { + junk [4]int + mu sync.Mutex + srv *Server + gw *gateway + msgb [100]byte +} + +type gateway struct { + cfg *gatewayCfg + outsim *sync.Map +} + +type gatewayCfg struct { + replyPfx []byte +} + +type Account struct { + Name string +} + +type Server struct { + gateway *srvGateway +} + +type srvGateway struct { + outo []*client +} + +type subscription struct { + queue []byte + client *client +} + +type outsie struct { + ni map[string]struct{} + sl *Sublist + qsubs int +} + +type Sublist struct { +} + +type SublistResult struct { + psubs []*subscription + qsubs [][]*subscription +} + +var subPool = &sync.Pool{} + +func (c *client) sendMsgToGateways(acc *Account, msg, subject, reply []byte, qgroups [][]byte) { + var gws []*client + gw := c.srv.gateway + for i := 0; i < len(gw.outo); i++ { + gws = append(gws, gw.outo[i]) + } + var ( + subj = string(subject) + queuesa = [512]byte{} + queues = queuesa[:0] + mreply []byte + dstPfx []byte + checkReply = len(reply) > 0 + ) + + sub := subPool.Get().(*subscription) + + if subjectStartsWithGatewayReplyPrefix(subject) { + dstPfx = subject[:8] + } + for i := 0; i < len(gws); i++ { + gwc := gws[i] + if dstPfx != nil { + gwc.mu.Lock() + ok := bytes.Equal(dstPfx, gwc.gw.cfg.replyPfx) + gwc.mu.Unlock() + if !ok { + continue + } + } else { + qr := gwc.gatewayInterest(acc.Name, subj) + queues = queuesa[:0] + for i := 0; i < len(qr.qsubs); i++ { + qsubs := qr.qsubs[i] + queue := qsubs[0].queue + add := true + for _, qn := range qgroups { + if bytes.Equal(queue, qn) { + add = false + break + } + } + if add { + qgroups = append(qgroups, queue) + } + } + if len(queues) == 0 { + continue + } + } + if checkReply { + checkReply = false + mreply = reply + } + mh := c.msgb[:10] + mh = append(mh, subject...) + if len(queues) > 0 { + mh = append(mh, mreply...) + mh = append(mh, queues...) + } + sub.client = gwc + } + subPool.Put(sub) +} + +func subjectStartsWithGatewayReplyPrefix(subj []byte) bool { + return len(subj) > 8 && string(subj[:4]) == "foob" +} + +func (c *client) gatewayInterest(acc, subj string) *SublistResult { + ei, _ := c.gw.outsim.Load(acc) + var r *SublistResult + e := ei.(*outsie) + r = e.sl.Match(subj) + return r +} + +func (s *Sublist) Match(subject string) *SublistResult { + return nil +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33386.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33386.go new file mode 100644 index 0000000000000000000000000000000000000000..a7074069febca11ac669f4f41de8046228e7f2ad --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33386.go @@ -0,0 +1,29 @@ +// errorcheck + +// Copyright 2019 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. + +// Verify that we don't get spurious follow-on errors +// after a missing expression. Specifically, the parser +// shouldn't skip over closing parentheses of any kind. + +package p + +func _() { + go func() { // no error here about goroutine + send <- // GCCGO_ERROR "undefined name" + }() // ERROR "expected expression|expected operand" +} + +func _() { + defer func() { // no error here about deferred function + 1 + // GCCGO_ERROR "value computed is not used" + }() // ERROR "expected expression|expected operand" +} + +func _() { + _ = (1 +) // ERROR "expected expression|expected operand" + _ = a[2 +] // ERROR "expected expression|expected operand|undefined name" + _ = []int{1, 2, 3 + } // ERROR "expected expression|expected operand" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33438.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33438.go new file mode 100644 index 0000000000000000000000000000000000000000..e4206d7bcfddb386a8360ada38e94d3dccbca21f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33438.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2019 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 p + +type hasPtrs struct { + x [2]*int + // Note: array size needs to be >1 to force this type to be not SSAable. + // The bug triggers only for OpMove, which is only used for unSSAable types. +} + +func main() { + var x *hasPtrs // Can be local, global, or arg; nil or non-nil. + var y *hasPtrs = nil // Must initialize to nil. + *x = *y +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33460.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33460.go new file mode 100644 index 0000000000000000000000000000000000000000..dff468a12cc7f92d2cb4ff350f18cac0230b1f64 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33460.go @@ -0,0 +1,37 @@ +// errorcheck + +// Copyright 2019 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 p + +const ( + zero = iota + one + two + three +) + +const iii int = 0x3 + +func f(v int) { + switch v { + case zero, one: + case two, one: // ERROR "previous case at LINE-1|duplicate case .*in.* switch" + + case three: + case 3: // ERROR "previous case at LINE-1|duplicate case .*in.* switch" + case iii: // ERROR "previous case at LINE-2|duplicate case .*in.* switch" + } +} + +const b = "b" + +var _ = map[string]int{ + "a": 0, + b: 1, + "a": 2, // ERROR "previous key at LINE-2|duplicate key.*in map literal" + "b": 3, // GC_ERROR "previous key at LINE-2|duplicate key.*in map literal" + "b": 4, // GC_ERROR "previous key at LINE-3|duplicate key.*in map literal" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33555.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33555.go new file mode 100644 index 0000000000000000000000000000000000000000..90d024470f718a85c2ebbead06856ba9c2c7e255 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33555.go @@ -0,0 +1,82 @@ +// run + +//go:build !nacl && !js && !wasip1 && !gccgo + +// Copyright 2019 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. + +// Test that the linker permits long call sequences. +package main + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "os/exec" + "path/filepath" + "strconv" +) + +const start = ` +package main + +func main() { + println(f0() + 1) +} +` + +const fn = ` +//go:noinline +func f%d() int { + return f%d() + 1 +}` + +const fnlast = ` +//go:noinline +func f%d() int { + return 0 +} +` + +const count = 400 + +func main() { + if err := test(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } +} + +func test() error { + var buf bytes.Buffer + buf.WriteString(start) + for i := 0; i < count; i++ { + fmt.Fprintf(&buf, fn, i, i + 1) + } + fmt.Fprintf(&buf, fnlast, count) + + dir, err := ioutil.TempDir("", "issue33555") + if err != nil { + return err + } + defer os.RemoveAll(dir) + + fn := filepath.Join(dir, "x.go") + if err := ioutil.WriteFile(fn, buf.Bytes(), 0644); err != nil { + return err + } + + out, err := exec.Command("go", "run", fn).CombinedOutput() + if err != nil { + return err + } + + want := strconv.Itoa(count + 1) + if got := string(bytes.TrimSpace(out)); got != want { + return fmt.Errorf("got %q want %q", got, want) + } + + return nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33724.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33724.go new file mode 100644 index 0000000000000000000000000000000000000000..a4ecddc0b32b1ea69ecf54e805ae2ee1609e97a4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33724.go @@ -0,0 +1,45 @@ +// run +package main + +import ( + "fmt" + "runtime/debug" + "strings" +) + +type Inner struct { + Err int +} + +func (i *Inner) NotExpectedInStackTrace() int { + if i == nil { + return 86 + } + return 17 + i.Err +} + +type Outer struct { + Inner +} + +func ExpectedInStackTrace() { + var o *Outer + println(o.NotExpectedInStackTrace()) +} + +func main() { + defer func() { + if r := recover(); r != nil { + stacktrace := string(debug.Stack()) + if strings.Contains(stacktrace, "NotExpectedInStackTrace") { + fmt.Println("FAIL, stacktrace contains NotExpectedInStackTrace") + } + if !strings.Contains(stacktrace, "ExpectedInStackTrace") { + fmt.Println("FAIL, stacktrace does not contain ExpectedInStackTrace") + } + } else { + fmt.Println("FAIL, should have panicked but did not") + } + }() + ExpectedInStackTrace() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33739.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33739.go new file mode 100644 index 0000000000000000000000000000000000000000..b7707822869fc21756202a568ecf4104d59c2d70 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33739.go @@ -0,0 +1,9 @@ +// rundir + +// Copyright 2019 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. + +// Issue 33739: gccgo undefined symbol with cross-package inlining + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33866.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33866.go new file mode 100644 index 0000000000000000000000000000000000000000..220c732a9a07c2a01c6768fa0f736392abcfa1e9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33866.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 33866: assert in gccgo during compilation + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue33903.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue33903.go new file mode 100644 index 0000000000000000000000000000000000000000..de03282264f8d718963841650c57ed1cbab400b7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue33903.go @@ -0,0 +1,16 @@ +// compile + +// Copyright 2019 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. + +// Check that the shortcircuit pass correctly handles infinite loops. + +package p + +func f() { + var p, q bool + for { + p = p && q + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34123.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34123.go new file mode 100644 index 0000000000000000000000000000000000000000..f50cd02aacf68e5e87f87cc8ac72947b3ae4d34d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34123.go @@ -0,0 +1,43 @@ +// run + +// Copyright 2019 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. + +// Make sure that the line number is reported correctly +// for faulting instructions. + +package main + +import ( + "fmt" + "runtime" +) + +var x byte +var p *byte + +//go:noinline +func f() { + q := p + x = 11 // line 23 + *q = 12 // line 24 +} +func main() { + defer func() { + recover() + var pcs [10]uintptr + n := runtime.Callers(1, pcs[:]) + frames := runtime.CallersFrames(pcs[:n]) + for { + f, more := frames.Next() + if f.Function == "main.f" && f.Line != 24 { + panic(fmt.Errorf("expected line 24, got line %d", f.Line)) + } + if !more { + break + } + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34329.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34329.go new file mode 100644 index 0000000000000000000000000000000000000000..790686e3ddfbd81a905a7df2644191984a9460f1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34329.go @@ -0,0 +1,14 @@ +// errorcheck -lang=go1.13 + +// Copyright 2019 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 p + +type I interface { M() } + +type _ interface { + I + I // ERROR "duplicate method M" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34395.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34395.go new file mode 100644 index 0000000000000000000000000000000000000000..eb5a8558e189e4d6d510e7df92e782cabfbf61f9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34395.go @@ -0,0 +1,17 @@ +// run + +// Copyright 2019 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. + +// Test that a binary with a large data section can load. This failed on wasm. + +package main + +var test = [100 * 1024 * 1024]byte{42} + +func main() { + if test[0] != 42 { + panic("bad") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34503.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34503.go new file mode 100644 index 0000000000000000000000000000000000000000..d843df7062826019cf906f9e1b7dfd87cad74c5e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34503.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 34503: gccgo compiler error importing inlinable function + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34520.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34520.go new file mode 100644 index 0000000000000000000000000000000000000000..d92d4ccbc52613697bcf63b5c635e3d7d415cfe3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34520.go @@ -0,0 +1,12 @@ +// compile + +// Copyright 2019 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 p + +func f() { + for true { + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34577.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34577.go new file mode 100644 index 0000000000000000000000000000000000000000..b4caaebb66c3249fdb54cead62e6224a02dd16f2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34577.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 34577: gccgo compiler error emitting export data + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34723.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34723.go new file mode 100644 index 0000000000000000000000000000000000000000..402d465aa40c494ceb0824345ca3c1f0adfa617b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34723.go @@ -0,0 +1,70 @@ +// errorcheck -0 -d=wb + +// Copyright 2019 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. + +// Make sure we don't introduce write barriers where we +// don't need them. These cases are writing pointers to +// globals to zeroed memory. + +package main + +func f1() []string { + return []string{"a"} +} + +func f2() []string { + return []string{"a", "b"} +} + +type T struct { + a [6]*int +} + +func f3() *T { + t := new(T) + t.a[0] = &g + t.a[1] = &g + t.a[2] = &g + t.a[3] = &g + t.a[4] = &g + t.a[5] = &g + return t +} + +func f4() *T { + t := new(T) + t.a[5] = &g + t.a[4] = &g + t.a[3] = &g + t.a[2] = &g + t.a[1] = &g + t.a[0] = &g + return t +} + +func f5() *T { + t := new(T) + t.a[4] = &g + t.a[2] = &g + t.a[0] = &g + t.a[3] = &g + t.a[1] = &g + t.a[5] = &g + return t +} + +type U struct { + a [65]*int +} + +func f6() *U { + u := new(U) + u.a[63] = &g + // This offset is too large: we only track the first 64 pointers for zeroness. + u.a[64] = &g // ERROR "write barrier" + return u +} + +var g int diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34966.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34966.go new file mode 100644 index 0000000000000000000000000000000000000000..f920e71a6d7965629a2180cfeb9db602ada65435 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34966.go @@ -0,0 +1,14 @@ +// compile -d=checkptr + +// Copyright 2019 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 p + +import "unsafe" + +type ptr unsafe.Pointer + +func f(p ptr) *int { return (*int)(p) } +func g(p ptr) ptr { return ptr(uintptr(p) + 1) } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue34968.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue34968.go new file mode 100644 index 0000000000000000000000000000000000000000..f328f04479e2cae210293eda3a87f2862c482ac3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue34968.go @@ -0,0 +1,16 @@ +// run -gcflags=all=-d=checkptr + +//go:build cgo + +// Copyright 2019 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 + +// #include +import "C" + +func main() { + C.malloc(100) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35027.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35027.go new file mode 100644 index 0000000000000000000000000000000000000000..d4b0be52c108bf71a1db94c76637c95d651f3ca0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35027.go @@ -0,0 +1,23 @@ +// run -gcflags=-d=checkptr + +// Copyright 2019 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 + +import ( + "reflect" + "unsafe" +) + +var s []int + +func main() { + s = []int{42} + h := (*reflect.SliceHeader)(unsafe.Pointer(&s)) + x := *(*int)(unsafe.Pointer(h.Data)) + if x != 42 { + panic(x) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35073a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35073a.go new file mode 100644 index 0000000000000000000000000000000000000000..dc8ce3a987530559f52b4477c45ba7bc85ce97fc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35073a.go @@ -0,0 +1,23 @@ +// run -gcflags=-d=checkptr + +// Copyright 2020 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. + +// Test that reflect.Value.UnsafeAddr/Pointer is handled +// correctly by -d=checkptr + +package main + +import ( + "reflect" + "unsafe" +) + +func main() { + n := 10 + m := make(map[string]string) + + _ = unsafe.Pointer(reflect.ValueOf(&n).Elem().UnsafeAddr()) + _ = unsafe.Pointer(reflect.ValueOf(&m).Elem().Pointer()) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35073b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35073b.go new file mode 100644 index 0000000000000000000000000000000000000000..8cdc6c184dca4771a90cf8e5ff471f2e90820430 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35073b.go @@ -0,0 +1,23 @@ +// errorcheck -0 -d=checkptr -m + +// Copyright 2020 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. + +// Test that we can inline the receiver arguments for +// reflect.Value.UnsafeAddr/Pointer, even in checkptr mode. + +package main + +import ( + "reflect" + "unsafe" +) + +func main() { + n := 10 // ERROR "moved to heap: n" + m := make(map[string]string) // ERROR "moved to heap: m" "make\(map\[string\]string\) escapes to heap" + + _ = unsafe.Pointer(reflect.ValueOf(&n).Elem().UnsafeAddr()) // ERROR "inlining call" + _ = unsafe.Pointer(reflect.ValueOf(&m).Elem().Pointer()) // ERROR "inlining call" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35157.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35157.go new file mode 100644 index 0000000000000000000000000000000000000000..c9c4899e0c855f9e521af407f8deabc70a41d727 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35157.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2019 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 p + +func f() { + var i int + var b *bool + var s0, s1, s2 string + + if *b { + s2 = s2[:1] + i = 1 + } + s1 = s1[i:-i+i] + s1[-i+i:i+2] + s1 = s0[i:-i] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35291.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35291.go new file mode 100644 index 0000000000000000000000000000000000000000..f6cd45573c5e9e52e9f480e3dd6a2c2b9cfba3ff --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35291.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2019 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. + +// Check error message for duplicated index in slice literal + +package p + +var s = []string{ + 1: "dup", + 1: "dup", // ERROR "duplicate index in slice literal: 1|duplicate value for index 1|duplicate index 1" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35518.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35518.go new file mode 100644 index 0000000000000000000000000000000000000000..52a0ae7e62f1335cb44e4e5f294ff3071dd57237 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35518.go @@ -0,0 +1,44 @@ +// errorcheck -0 -l -m=2 + +// Copyright 2019 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. + +// This test makes sure that -m=2's escape analysis diagnostics don't +// go into an infinite loop when handling negative dereference +// cycles. The critical thing being tested here is that compilation +// succeeds ("errorcheck -0"), not any particular diagnostic output, +// hence the very lax ERROR patterns below. + +package p + +type Node struct { + Orig *Node +} + +var sink *Node + +func f1() { + var n Node // ERROR "." + n.Orig = &n + + m := n // ERROR "." + sink = &m +} + +func f2() { + var n1, n2 Node // ERROR "." + n1.Orig = &n2 + n2 = n1 + + m := n2 // ERROR "." + sink = &m +} + +func f3() { + var n1, n2 Node // ERROR "." + n1.Orig = &n1 + n1.Orig = &n2 + + sink = n1.Orig.Orig +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue3552.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue3552.go new file mode 100644 index 0000000000000000000000000000000000000000..a198dbe971f4c3fb168a98c2ccf7fbf32ad8ae8a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue3552.go @@ -0,0 +1,10 @@ +// compiledir + +// Copyright 2011 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. + +// Issue 3552: cross-package inlining misbehaves when +// referencing embedded builtins. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35576.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35576.go new file mode 100644 index 0000000000000000000000000000000000000000..8228555c9ac42ea0b9f711a5e9c101362f70f2b2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35576.go @@ -0,0 +1,16 @@ +// run + +// Copyright 2019 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. + +// Check print/println(f()) is allowed where f() is multi-value. + +package main + +func f() (int16, float64, string) { return -42, 42.0, "x" } + +func main() { + print(f()) + println(f()) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35576.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue35576.out new file mode 100644 index 0000000000000000000000000000000000000000..2aefe3edc5a99c5e72729f86effa34d9ba8232f9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35576.out @@ -0,0 +1 @@ +-42+4.200000e+001x-42 +4.200000e+001 x diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35586.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35586.go new file mode 100644 index 0000000000000000000000000000000000000000..0d522b171427ec34c4c32df09a480b074680f6a3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35586.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 35586: gollvm compiler crash building docker-ce; the problem +// involves inlining a function that has multiple no-name ("_") parameters. +// + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35652.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35652.go new file mode 100644 index 0000000000000000000000000000000000000000..178a84d0f8b4ae559c4ef62810569642c1d8af0a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35652.go @@ -0,0 +1,28 @@ +// compile + +// Copyright 2019 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 p + +func e() { + for true { + if true { + continue + } + } +} + +func g() {} + +func f() { + i := 0 + if true { + i++ + } + for true { + continue + g() + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue35739.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue35739.go new file mode 100644 index 0000000000000000000000000000000000000000..26f09d8c1bf8774f9cd8dd55ad5716f6bd658753 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue35739.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2020 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. + +// Issue 35739: gccgo inlining error with constant with method. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue36085.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue36085.go new file mode 100644 index 0000000000000000000000000000000000000000..69d4490fd5aade83d8c046210e3a6538bf5c9570 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue36085.go @@ -0,0 +1,11 @@ +// compiledir + +// Copyright 2019 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. + +// Issue 36085: gccgo compiler did not generate type descriptor +// for pointer to type alias defined in another package, causing +// linking error. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue36259.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue36259.go new file mode 100644 index 0000000000000000000000000000000000000000..246eb3527ef2289529950ca9064b957b375d3564 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue36259.go @@ -0,0 +1,28 @@ +// compile + +// Copyright 2019 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 rotate(s []int, m int) { + l := len(s) + m = m % l + buf := make([]int, m) + + copy(buf, s) + copy(s, s[m:]) + copy(s[l-m:], buf) +} + +func main() { + a0 := [...]int{1,2,3,4,5} + println(a0[0]) + + rotate(a0[:], 1) + println(a0[0]) + + rotate(a0[:], -3) + println(a0[0]) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue36437.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue36437.go new file mode 100644 index 0000000000000000000000000000000000000000..72ea50bdadaf6bb584673bf9ccf28e508fad0f12 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue36437.go @@ -0,0 +1,49 @@ +// run + +//go:build !nacl && !js && !wasip1 && gc + +// Copyright 2020 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. + +// Tests that when non-existent files are passed to the +// compiler, such as in: +// go tool compile foo +// we don't print the beginning position: +// foo:0: open foo: no such file or directory +// but instead omit it and print out: +// open foo: no such file or directory + +package main + +import ( + "fmt" + "io/ioutil" + "os" + "os/exec" + "regexp" +) + +func main() { + tmpDir, err := ioutil.TempDir("", "issue36437") + if err != nil { + panic(err) + } + defer os.RemoveAll(tmpDir) + + msgOrErr := func(msg []byte, err error) string { + if len(msg) == 0 && err != nil { + return err.Error() + } + return string(msg) + } + + filename := "non-existent.go" + output, err := exec.Command("go", "tool", "compile", filename).CombinedOutput() + got := msgOrErr(output, err) + + regFilenamePos := regexp.MustCompile(filename + ":\\d+") + if regFilenamePos.MatchString(got) { + fmt.Printf("Error message must not contain filename:pos, but got:\n%q\n", got) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue36516.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue36516.go new file mode 100644 index 0000000000000000000000000000000000000000..68f655a568de5038210b3e38996c99c59fd7b1ef --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue36516.go @@ -0,0 +1,28 @@ +// run -race + +//go:build cgo && linux && amd64 + +// Copyright 2020 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 + +import ( + "fmt" + "testing" + "unsafe" +) + +var buf [2]byte +var x unsafe.Pointer = unsafe.Pointer(&buf[0]) + +func main() { + n := testing.AllocsPerRun(1000, func() { + x = unsafe.Pointer(uintptr(x) + 1) + x = unsafe.Pointer(uintptr(x) - 1) + }) + if n > 0 { + panic(fmt.Sprintf("too many allocations; want 0 got %f", n)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue36705.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue36705.go new file mode 100644 index 0000000000000000000000000000000000000000..9aad8a7f813edbe1c4b8419ea0978cf6c010c0f3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue36705.go @@ -0,0 +1,28 @@ +// run fake-arg-to-force-use-of-go-run + +//go:build cgo && !windows + +// Copyright 2020 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 + +// #include +// #include +import "C" + +import "os" + +func main() { + os.Setenv("FOO", "bar") + s := C.GoString(C.getenv(C.CString("FOO"))) + if s != "bar" { + panic("bad setenv, environment variable only has value \"" + s + "\"") + } + os.Unsetenv("FOO") + s = C.GoString(C.getenv(C.CString("FOO"))) + if s != "" { + panic("bad unsetenv, environment variable still has value \"" + s + "\"") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue36723.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue36723.go new file mode 100644 index 0000000000000000000000000000000000000000..e748d9a75c0558d6e9d6d46cb75fae39c97791c8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue36723.go @@ -0,0 +1,26 @@ +// compile -d=ssa/check/on + +// Copyright 2020 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. + +// Issue 36723: fail to compile on PPC64 when SSA check is on. + +package p + +import "unsafe" + +type T struct { + a, b, c, d uint8 + x [10]int32 +} + +func F(p *T, i uintptr) int32 { + // load p.x[i] using unsafe, derived from runtime.pcdatastart + _ = *p + return *(*int32)(add(unsafe.Pointer(&p.d), unsafe.Sizeof(p.d)+i*unsafe.Sizeof(p.x[0]))) +} + +func add(p unsafe.Pointer, x uintptr) unsafe.Pointer { + return unsafe.Pointer(uintptr(p) + x) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue3705.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue3705.go new file mode 100644 index 0000000000000000000000000000000000000000..ed0a193dcfbb54579abf9b5500734ddd0a9cfedf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue3705.go @@ -0,0 +1,9 @@ +// errorcheck + +// Copyright 2012 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 p + +func init() // ERROR "missing function body|cannot declare init" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue37246.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue37246.go new file mode 100644 index 0000000000000000000000000000000000000000..fe476daa39b4b2321b45a2a5d87f4e423c0d0739 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue37246.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2020 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 main() { + var n, a, b int64 + for i := int64(2); i < 10; i++ { + for j := i; j < 10; j++ { + if ((n % (i * j)) == 0) && (j > 1 && (n/(i*j)) == 1) { + a, b = i, 0 + a = n / (i * j) + } + } + } + + if a != b && a != n { + println("yes") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue37513.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue37513.go new file mode 100644 index 0000000000000000000000000000000000000000..957032519cab6430ccd9bb25ced7ec221039984a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue37513.go @@ -0,0 +1,9 @@ +// buildrundir + +// Copyright 2020 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. + +//go:build (linux && amd64) || (darwin && amd64) || (linux && 386) + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue37716.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue37716.go new file mode 100644 index 0000000000000000000000000000000000000000..42d66dff1bd1090e54ed7ebdf2a20dbeb8405aaa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue37716.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2020 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 + +import "reflect" + +// complicated enough to require a compile-generated hash function +type K struct { + a, b int32 // these get merged by the compiler into a single field, something typehash doesn't do + c float64 +} + +func main() { + k := K{a: 1, b: 2, c: 3} + + // Make a reflect map. + m := reflect.MakeMap(reflect.MapOf(reflect.TypeOf(K{}), reflect.TypeOf(true))) + m.SetMapIndex(reflect.ValueOf(k), reflect.ValueOf(true)) + + // The binary must not contain the type map[K]bool anywhere, or reflect.MapOf + // will use that type instead of making a new one. So use an equivalent named type. + type M map[K]bool + var x M + reflect.ValueOf(&x).Elem().Set(m) + if !x[k] { + panic("key not found") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue37753.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue37753.go new file mode 100644 index 0000000000000000000000000000000000000000..ac311e371531d6e03524f67c2a7101a2ecb23e07 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue37753.go @@ -0,0 +1,18 @@ +// run + +// Copyright 2020 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 + +//go:noinline +func f(a, b uint) int { + return int(a-b) / 8 +} + +func main() { + if x := f(1, 2); x != 0 { + panic(x) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue3783.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue3783.go new file mode 100644 index 0000000000000000000000000000000000000000..7db06d1881dcd44869073277ac74ddf604a2f961 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue3783.go @@ -0,0 +1,12 @@ +// errorcheck + +// Copyright 2012 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 foo + +var i int + +func (*i) bar() // ERROR "not a type|expected type" + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue37837.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue37837.go new file mode 100644 index 0000000000000000000000000000000000000000..2e8abc5f05769715594edb0b8094b319a082b2ef --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue37837.go @@ -0,0 +1,7 @@ +// errorcheckandrundir -0 -m + +// Copyright 2020 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue37975.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue37975.go new file mode 100644 index 0000000000000000000000000000000000000000..a4e8f1f14aaacb9839b792f0cb1b25c28879edf1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue37975.go @@ -0,0 +1,54 @@ +// run + +// Copyright 2020 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. + +// Make sure runtime.panicmakeslice* are called. + +package main + +import "strings" + +func main() { + // Test typechecking passes if len is valid + // but cap is out of range for len's type. + var x byte + _ = make([]int, x, 300) + + capOutOfRange := func() { + i := 2 + s := make([]int, i, 1) + s[0] = 1 + } + lenOutOfRange := func() { + i := -1 + s := make([]int, i, 3) + s[0] = 1 + } + + tests := []struct { + f func() + panicStr string + }{ + {capOutOfRange, "cap out of range"}, + {lenOutOfRange, "len out of range"}, + } + + for _, tc := range tests { + shouldPanic(tc.panicStr, tc.f) + } + +} + +func shouldPanic(str string, f func()) { + defer func() { + err := recover() + runtimeErr := err.(error).Error() + if !strings.Contains(runtimeErr, str) { + panic("got panic " + runtimeErr + ", want " + str) + } + }() + + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38093.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38093.go new file mode 100644 index 0000000000000000000000000000000000000000..af476aba48a3e1c43cbffd7fe14242fd71c00c9f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38093.go @@ -0,0 +1,50 @@ +// run + +//go:build js + +// Copyright 2020 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. + +// Test race condition between timers and wasm calls that led to memory corruption. + +package main + +import ( + "os" + "syscall/js" + "time" +) + +func main() { + ch1 := make(chan struct{}) + + go func() { + for { + time.Sleep(5 * time.Millisecond) + ch1 <- struct{}{} + } + }() + go func() { + for { + time.Sleep(8 * time.Millisecond) + ch1 <- struct{}{} + } + }() + go func() { + time.Sleep(2 * time.Second) + os.Exit(0) + }() + + for range ch1 { + ch2 := make(chan struct{}, 1) + f := js.FuncOf(func(this js.Value, args []js.Value) interface{} { + ch2 <- struct{}{} + return nil + }) + defer f.Release() + fn := js.Global().Get("Function").New("cb", "cb();") + fn.Invoke(f) + <-ch2 + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38117.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38117.go new file mode 100644 index 0000000000000000000000000000000000000000..c0707ef6dc7be603a6f2b141cdf0f6715764a9b3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38117.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2020 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. + +// cmd/compile erroneously rejected conversions of constant values +// between int/float and complex types. + +package p + +const ( + _ = int(complex64(int(0))) + _ = float64(complex128(float64(0))) + + _ = int8(complex128(1000)) // ERROR "overflow|cannot convert" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38125.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38125.go new file mode 100644 index 0000000000000000000000000000000000000000..1207aecd39b2f5d285c0def69c2ec5872f751a64 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38125.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2020 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. + +// gccgo mishandled embedded methods of type aliases. + +package p + +type I int + +func (I) M() {} + +type T = struct { + I +} + +func F() { + _ = T.M + _ = struct { I }.M +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38356.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38356.go new file mode 100644 index 0000000000000000000000000000000000000000..a1c7f4675a2077808a9e2897fecc0f041e7ee602 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38356.go @@ -0,0 +1,54 @@ +// compile + +// Copyright 2020 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. + +// Make sure floating point operations that generate flags +// are scheduled correctly on s390x. + +package p + +func f1(x, y float64, z int) float64 { + a := x + y // generate flags + if z == 0 { // create basic block that does not clobber flags + return a + } + if a > 0 { // use flags in different basic block + return y + } + return x +} + +func f2(x, y float64, z int) float64 { + a := x - y // generate flags + if z == 0 { // create basic block that does not clobber flags + return a + } + if a > 0 { // use flags in different basic block + return y + } + return x +} + +func f3(x, y float32, z int) float32 { + a := x + y // generate flags + if z == 0 { // create basic block that does not clobber flags + return a + } + if a > 0 { // use flags in different basic block + return y + } + return x +} + +func f4(x, y float32, z int) float32 { + a := x - y // generate flags + if z == 0 { // create basic block that does not clobber flags + return a + } + if a > 0 { // use flags in different basic block + return y + } + return x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38359.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38359.go new file mode 100644 index 0000000000000000000000000000000000000000..a7550c7b2cc054d24c61ad31b83dde7ff59f1fa4 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38359.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2020 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. + +// Make sure NaN-NaN compiles correctly. + +package p + +func f() { + var st struct { + f float64 + _, _ string + } + + f := 1e308 + st.f = 2*f - 2*f +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38496.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38496.go new file mode 100644 index 0000000000000000000000000000000000000000..717aa5d41d68f500eff974b629951731b333b61a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38496.go @@ -0,0 +1,20 @@ +// run + +// Copyright 2020 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. + +// Make sure bounds check elision isn't confused with nil check elision. + +package main + +func main() { + defer func() { + err := recover() + if err == nil { + panic("failed to check nil ptr") + } + }() + var m [2]*int + _ = *m[1] // need a nil check, but not a bounds check +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38690.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38690.go new file mode 100644 index 0000000000000000000000000000000000000000..af8688d12fb0a4493200c25260131a84f2dbebf0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38690.go @@ -0,0 +1,65 @@ +// compile + +// Copyright 2020 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. + +// Make sure that literal value can be passed to struct +// blank field of array/struct type, see issue #38690. + +package main + +type A1 = [0]int +type A2 = [1]int + +type S1 struct{} + +type S2 struct { + x int +} + +type S3 = struct{} + +type S4 = struct{ x int } + +type S struct { + x int + _ [0]int + _ [1]int + _ A1 + _ A2 + _ S1 + _ S2 + _ S3 + _ S4 + _ [1]S4 +} + +var s = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, S4{1}, [1]S4{}} + +func main() { + f1() + mustPanic(f2) + mustPanic(f3) +} + +func f1() { + _ = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, S4{1}, [1]S4{}} +} + +func f2() { + _ = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, func() S4 { panic("") }(), [1]S4{}} +} + +func f3() { + _ = S{1, [0]int{}, [1]int{1}, A1{}, A2{1}, S1{}, S2{1}, S3{}, S4{1}, func() [1]S4 { panic("") }()} +} + +func mustPanic(f func()) { + defer func() { + if recover() == nil { + panic("expected panic, got nil") + } + }() + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38698.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38698.go new file mode 100644 index 0000000000000000000000000000000000000000..819e223791ac334138db6ac49b54f7ede0c55f4f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38698.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2021 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. + +// This test case caused a panic in the compiler's DWARF gen code. + +package p + +func ff( /*line :10*/ x string) bool { + { + var _ /*line :10*/, x int + _ = x + } + return x == "" +} + + +func h(a string) bool { + return ff(a) +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38745.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38745.go new file mode 100644 index 0000000000000000000000000000000000000000..3a84a5622bc4d44060ddaf3da6bc11db1b3ec712 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38745.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2020 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 p + +type t struct{ x int } + +func f1() { + t{}.M() // ERROR "t{}.M undefined \(type t has no field or method M\)|undefined field or method .*M" + t{x: 1}.M() // ERROR "t{...}.M undefined \(type t has no field or method M\)|undefined field or method .*M|no field or method M" +} + +func f2() (*t, error) { + return t{}.M() // ERROR "t{}.M undefined \(type t has no field or method M\)|undefined field or method .*M|not enough arguments" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38746.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38746.go new file mode 100644 index 0000000000000000000000000000000000000000..c670349ed4a747cf10df4c78fadb2b68edaf603b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38746.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2020 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 + +var g *uint64 + +func main() { + var v uint64 + g = &v + v &^= (1 << 31) + v |= 1 << 63 + v &^= (1 << 63) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38905.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38905.go new file mode 100644 index 0000000000000000000000000000000000000000..6f411b860553cba64717d5c5886ef385bf2f5e4d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38905.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2020 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. + +// Make sure that literal value can be passed to struct +// blank field with expressions where candiscard(value) +// returns false, see #38905. + +package p + +type t struct{ _ u } +type u [10]struct{ f int } + +func f(x int) t { return t{u{{1 / x}, {1 % x}}} } +func g(p *int) t { return t{u{{*p}}} } +func h(s []int) t { return t{u{{s[0]}}} } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue38916.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue38916.go new file mode 100644 index 0000000000000000000000000000000000000000..fb2ee3459d5d38d121aaa2e07415a184f9783c10 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue38916.go @@ -0,0 +1,14 @@ +// compile + +// Copyright 2020 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 p + +func f(b bool, c complex128) func(complex128) complex128 { + return func(p complex128) complex128 { + b = (p+1i == 0) && b + return (p + 2i) * (p + 3i - c) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue3925.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue3925.go new file mode 100644 index 0000000000000000000000000000000000000000..f0851878ec7268bfc12ab2bb936eb09179981061 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue3925.go @@ -0,0 +1,23 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 3925: wrong line number for error message "missing key in map literal" + +// also a test for correct line number in other malformed composite literals. + +package foo + +var _ = map[string]string{ + "1": "2", + "3", "4", // ERROR "missing key|must have keys" +} + +var _ = []string{ + "foo", + "bar", + 20, // ERROR "cannot use|incompatible type|cannot convert" +} + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue39292.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue39292.go new file mode 100644 index 0000000000000000000000000000000000000000..7dac2e5fc6b6398f598518ef6eae60b2b5eeb45e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue39292.go @@ -0,0 +1,29 @@ +// errorcheck -0 -m -l + +// Copyright 2020 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 p + +type t [20000]*int + +func (t) f() { +} + +func x() { + x := t{}.f // ERROR "t{}.f escapes to heap" + x() +} + +func y() { + var i int // ERROR "moved to heap: i" + y := (&t{&i}).f // ERROR "\(&t{...}\).f escapes to heap" "&t{...} escapes to heap" + y() +} + +func z() { + var i int // ERROR "moved to heap: i" + z := t{&i}.f // ERROR "t{...}.f escapes to heap" + z() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue39459.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue39459.go new file mode 100644 index 0000000000000000000000000000000000000000..de78a17ce283871fdf41b19c1d13e5d1ac12f84e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue39459.go @@ -0,0 +1,22 @@ +// compile + +// Copyright 2020 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 p + +type T struct { // big enough to be an unSSAable type + a, b, c, d, e, f int +} + +func f(x interface{}, p *int) { + _ = *p // trigger nil check here, removing it from below + switch x := x.(type) { + case *T: + // Zero twice, so one of them will be removed by the deadstore pass + *x = T{} + *p = 0 // store op to prevent Zero ops from being optimized by the earlier opt pass rewrite rules + *x = T{} + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue39472.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue39472.go new file mode 100644 index 0000000000000000000000000000000000000000..61444a28b91b935537d7f02ac2850fb3f28a5170 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue39472.go @@ -0,0 +1,12 @@ +// compile -N + +// Copyright 2020 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 p + +func f(x float64) bool { + x += 1 + return (x != 0) == (x != 0) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue39505.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue39505.go new file mode 100644 index 0000000000000000000000000000000000000000..711b562867af30cc4b93eb28105900b7eccf59b9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue39505.go @@ -0,0 +1,31 @@ +// compile + +// Copyright 2020 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 p + +func f() { + if len([]int{})-1 < len([]int{}) { + } + + var st struct { + i int + } + g := func() string { + return "" + } + h := func(string) string { + return g() + g() + } + s, i := "", 0 + + st.i = len(s) + i = len(h(s[i+0:i+1])) + len(s[len(s)+1:i+1]) + s = s[(len(s[i+1:len(s)+1])+1):len(h(""))+1] + (s[i+1 : len([]int{})+i]) + i = 1 + len([]int{len([]string{s[i+len([]int{}) : len(s)+i]})}) + + var ch chan int + ch <- len(h("")) - len(s) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue39505b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue39505b.go new file mode 100644 index 0000000000000000000000000000000000000000..ecf1ab64f417d5d591a1712fd92cb94cc34fb48f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue39505b.go @@ -0,0 +1,183 @@ +// run + +// Copyright 2020 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 main() { + ff := []func(){lt_f1, lt_f2, lt_f3, lt_f4, lt_f5, lt_f6, lt_f7, lt_f8, lt_f9, + gt_f1, gt_f2, gt_f3, le_f1, le_f2, le_f3, ge_f1, ge_f2, ge_f3} + + for _, f := range ff { + f() + } +} + +func lt_f1() { + const c = 1 + var a = 0 + var v *int = &a + if *v-c < len([]int{}) { + } else { + panic("bad") + } +} + +func lt_f2() { + const c = 10 + var a = 0 + var v *int = &a + if *v+c < len([]int{}) { + panic("bad") + } +} + +func lt_f3() { + const c = -10 + var a = 0 + var v *int = &a + if *v|0xff+c < len([]int{}) { + panic("bad") + } +} + +func lt_f4() { + const c = 10 + var a = 0 + var v *int = &a + if *v|0x0f+c < len([]int{}) { + panic("bad") + } +} + +func lt_f5() { + const c int32 = 1 + var a int32 = 0 + var v *int32 = &a + if *v-c < int32(len([]int32{})) { + } else { + panic("bad") + } +} + +func lt_f6() { + const c int32 = 10 + var a int32 = 0 + var v *int32 = &a + if *v+c < int32(len([]int32{})) { + panic("bad") + } +} + +func lt_f7() { + const c int32 = -10 + var a int32 = 0 + var v *int32 = &a + if *v|0xff+c < int32(len([]int{})) { + panic("bad") + } +} + +func lt_f8() { + const c int32 = 10 + var a int32 = 0 + var v *int32 = &a + if *v|0x0f+c < int32(len([]int{})) { + panic("bad") + } +} + +func lt_f9() { + const c int32 = -10 + var a int32 = 0 + var v *int32 = &a + if *v|0x0a+c < int32(len([]int{})) { + panic("bad") + } +} + +func gt_f1() { + const c = 1 + var a = 0 + var v *int = &a + if len([]int{}) > *v-c { + } else { + panic("bad") + } +} + +func gt_f2() { + const c = 10 + var a = 0 + var v *int = &a + if len([]int{}) > *v|0x0f+c { + panic("bad") + } +} + +func gt_f3() { + const c int32 = 10 + var a int32 = 0 + var v *int32 = &a + if int32(len([]int{})) > *v|0x0f+c { + panic("bad") + } +} + +func le_f1() { + const c = -10 + var a = 0 + var v *int = &a + if *v|0xff+c <= len([]int{}) { + panic("bad") + } +} + +func le_f2() { + const c = 0xf + var a = 0 + var v *int = &a + if *v|0xf-c <= len([]int{}) { + } else { + panic("bad") + } +} + +func le_f3() { + const c int32 = -10 + var a int32 = 0 + var v *int32 = &a + if *v|0xff+c <= int32(len([]int{})) { + panic("bad") + } +} + +func ge_f1() { + const c = -10 + var a = 0 + var v *int = &a + if len([]int{}) >= *v|0xff+c { + panic("bad") + } +} + +func ge_f2() { + const c int32 = 10 + var a int32 = 0 + var v *int32 = &a + if int32(len([]int{})) >= *v|0x0f+c { + panic("bad") + } +} + +func ge_f3() { + const c = -10 + var a = 0 + var v *int = &a + if len([]int{}) >= *v|0x0a+c { + } else { + panic("bad") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue39541.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue39541.go new file mode 100644 index 0000000000000000000000000000000000000000..fba52916ebe350e1157aa80440412dab10ca3f28 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue39541.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2020 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 + +import "reflect" + +func sub(args []reflect.Value) []reflect.Value { + type A struct { + s int + t int + } + return []reflect.Value{reflect.ValueOf(A{1, 2})} +} + +func main() { + f := reflect.MakeFunc(reflect.TypeOf((func() interface{})(nil)), sub).Interface().(func() interface{}) + c := make(chan bool, 100) + for i := 0; i < 100; i++ { + go func() { + for j := 0; j < 10000; j++ { + f() + } + c <- true + }() + } + for i := 0; i < 100; i++ { + <-c + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue39651.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue39651.go new file mode 100644 index 0000000000000000000000000000000000000000..256a34dcb34832fb1f17ba601ce128735524f8d7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue39651.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2020 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. + +// Test that float -> integer conversion doesn't clobber +// flags. + +package main + +//go:noinline +func f(x, y float64, a, b *bool, r *int64) { + *a = x < y // set flags + *r = int64(x) // clobber flags + *b = x == y // use flags +} + +func main() { + var a, b bool + var r int64 + f(1, 1, &a, &b, &r) + if a || !b { + panic("comparison incorrect") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue40152.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue40152.go new file mode 100644 index 0000000000000000000000000000000000000000..1cb68e99145140b1efd120486272c7b3e3d810c6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue40152.go @@ -0,0 +1,21 @@ +// run + +// Copyright 2020 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. + +// Gccgo mishandles converting an untyped boolean to an interface type. + +package main + +func t(args ...interface{}) bool { + x := true + return x == args[0] +} + +func main() { + r := t("x" == "x" && "y" == "y") + if !r { + panic(r) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue40252.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue40252.go new file mode 100644 index 0000000000000000000000000000000000000000..9be4e665d2923d4183f637501244a33922659b48 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue40252.go @@ -0,0 +1,8 @@ +// rundir + +// Copyright 2020 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. + +// gccgo got an undefined symbol reference when inlining a method expression. +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue40367.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue40367.go new file mode 100644 index 0000000000000000000000000000000000000000..0dc5ad71206733155fa1be42124e9aa73fd05ad2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue40367.go @@ -0,0 +1,41 @@ +// run + +// Copyright 2020 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 case1() { + rates := []int32{1,2,3,4,5,6} + var sink [6]int + j := len(sink) + for star, _ := range rates { + if star+1 < 1 { + panic("") + } + j-- + sink[j] = j + } +} + +func case2() { + i := 0 + var sink [3]int + j := len(sink) +top: + j-- + sink[j] = j + if i < 2 { + i++ + if i < 1 { + return + } + goto top + } +} + +func main() { + case1() + case2() +} \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue40629.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue40629.go new file mode 100644 index 0000000000000000000000000000000000000000..c6ef408f49476288ed6248ff19f62591bf986110 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue40629.go @@ -0,0 +1,69 @@ +// run + +// Copyright 2020 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 + +import "fmt" + +const N = 40 + +func main() { + var x [N]int // stack-allocated memory + for i := range x { + x[i] = 0x999 + } + + // This defer checks to see if x is uncorrupted. + defer func(p *[N]int) { + recover() + for i := range p { + if p[i] != 0x999 { + for j := range p { + fmt.Printf("p[%d]=0x%x\n", j, p[j]) + } + panic("corrupted stack variable") + } + } + }(&x) + + // This defer starts a new goroutine, which will (hopefully) + // overwrite x on the garbage stack. + defer func() { + c := make(chan bool) + go func() { + useStack(1000) + c <- true + }() + <-c + + }() + + // This defer causes a stack copy. + // The old stack is now garbage. + defer func() { + useStack(1000) + }() + + // Trigger a segfault. + *g = 0 + + // Make the return statement unreachable. + // That makes the stack map at the deferreturn call empty. + // In particular, the argument to the first defer is not + // marked as a pointer, so it doesn't get adjusted + // during the stack copy. + for { + } +} + +var g *int64 + +func useStack(n int) { + if n == 0 { + return + } + useStack(n - 1) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4066.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4066.go new file mode 100644 index 0000000000000000000000000000000000000000..19cfe6651a7f352667579f05eaee8b598b588cfb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4066.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2012 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. + +// issue 4066: return values not being spilled eagerly enough + +package main + +func main() { + n := foo() + if n != 2 { + println(n) + panic("wrong return value") + } +} + +type terr struct{} + +func foo() (val int) { + val = 0 + defer func() { + if x := recover(); x != nil { + _ = x.(terr) + } + }() + for { + val = 2 + foo1() + } + panic("unreachable") +} + +func foo1() { + panic(terr{}) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue40746.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue40746.go new file mode 100644 index 0000000000000000000000000000000000000000..235282fd90c544fbf1673125013520d42e5fe6b9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue40746.go @@ -0,0 +1,19 @@ +// compile + +// Copyright 2020 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 p + +func f(x byte, b bool) byte { + var c byte + if b { + c = 1 + } + + if int8(c) < 0 { + x++ + } + return x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4085a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4085a.go new file mode 100644 index 0000000000000000000000000000000000000000..bf97c9e4494548e1538182b2ae15e9181590d387 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4085a.go @@ -0,0 +1,18 @@ +// errorcheck + +// Copyright 2013 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 + +type T []int + +func main() { + _ = make(T, -1) // ERROR "negative" + _ = make(T, 0.5) // ERROR "constant 0.5 truncated to integer|non-integer len argument|truncated to int" + _ = make(T, 1.0) // ok + _ = make(T, 1<<63) // ERROR "len argument too large|overflows int" + _ = make(T, 0, -1) // ERROR "negative cap|must not be negative" + _ = make(T, 10, 0) // ERROR "len larger than cap|length and capacity swapped" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4085b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4085b.go new file mode 100644 index 0000000000000000000000000000000000000000..cf27512da0b7f11ebe258de95d3a7ea5fd41de36 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4085b.go @@ -0,0 +1,85 @@ +// run + +// Copyright 2013 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 + +import ( + "strings" + "unsafe" +) + +type T []int + +func main() { + n := -1 + shouldPanic("len out of range", func() { _ = make(T, n) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, n) }) + shouldPanic("len out of range", func() { _ = make(T, int64(n)) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, int64(n)) }) + testMakeInAppend(n) + + var t *byte + if unsafe.Sizeof(t) == 8 { + // Test mem > maxAlloc + var n2 int64 = 1 << 59 + shouldPanic("len out of range", func() { _ = make(T, int(n2)) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, int(n2)) }) + testMakeInAppend(int(n2)) + // Test elem.size*cap overflow + n2 = 1<<63 - 1 + shouldPanic("len out of range", func() { _ = make(T, int(n2)) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, int(n2)) }) + testMakeInAppend(int(n2)) + var x uint64 = 1<<64 - 1 + shouldPanic("len out of range", func() { _ = make([]byte, x) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, x) }) + testMakeInAppend(int(x)) + } else { + n = 1<<31 - 1 + shouldPanic("len out of range", func() { _ = make(T, n) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, n) }) + shouldPanic("len out of range", func() { _ = make(T, int64(n)) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, int64(n)) }) + testMakeInAppend(n) + var x uint64 = 1<<32 - 1 + shouldPanic("len out of range", func() { _ = make([]byte, x) }) + shouldPanic("cap out of range", func() { _ = make(T, 0, x) }) + testMakeInAppend(int(x)) + } +} + +func shouldPanic(str string, f func()) { + defer func() { + err := recover() + if err == nil { + panic("did not panic") + } + s := err.(error).Error() + if !strings.Contains(s, str) { + panic("got panic " + s + ", want " + str) + } + }() + + f() +} + +// Test make in append panics since the gc compiler optimizes makes in appends. +func testMakeInAppend(n int) { + lengths := []int{0, 1} + for _, length := range lengths { + t := make(T, length) + shouldPanic("len out of range", func() { _ = append(t, make(T, n)...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, n)...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, int64(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, int64(n))...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, uint64(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, uint64(n))...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, int(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, int(n))...) }) + shouldPanic("len out of range", func() { _ = append(t, make(T, uint(n))...) }) + shouldPanic("cap out of range", func() { _ = append(t, make(T, 0, uint(n))...) }) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue40917.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue40917.go new file mode 100644 index 0000000000000000000000000000000000000000..2128be5eca48bfe02bac711fa259d58851a4a198 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue40917.go @@ -0,0 +1,23 @@ +// run -gcflags=-d=checkptr + +// Copyright 2020 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 + +import "unsafe" + +func main() { + var x [2]uint64 + a := unsafe.Pointer(&x[1]) + + b := a + b = unsafe.Pointer(uintptr(b) + 2) + b = unsafe.Pointer(uintptr(b) - 1) + b = unsafe.Pointer(uintptr(b) &^ 1) + + if a != b { + panic("pointer arithmetic failed") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue40954.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue40954.go new file mode 100644 index 0000000000000000000000000000000000000000..0beaabb7439755853d0f4d247e423b3b40bf11a1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue40954.go @@ -0,0 +1,40 @@ +// run + +// Copyright 2020 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. + +//go:build cgo + +package main + +import ( + "runtime/cgo" + "unsafe" +) + +type S struct { + _ cgo.Incomplete + x int +} + +func main() { + var i int + p := (*S)(unsafe.Pointer(uintptr(unsafe.Pointer(&i)))) + v := uintptr(unsafe.Pointer(p)) + // p is a pointer to a not-in-heap type. Like some C libraries, + // we stored an integer in that pointer. That integer just happens + // to be the address of i. + // v is also the address of i. + // p has a base type which is marked not-in-heap, so it + // should not be adjusted when the stack is copied. + recurse(100, p, v) +} +func recurse(n int, p *S, v uintptr) { + if n > 0 { + recurse(n-1, p, v) + } + if uintptr(unsafe.Pointer(p)) != v { + panic("adjusted notinheap pointer") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4097.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4097.go new file mode 100644 index 0000000000000000000000000000000000000000..30b65bce8335d982141f0c6680cb157401452a37 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4097.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2012 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 foo + +var s [][10]int +const m = len(s[len(s)-1]) // ERROR "is not a constant|is not constant" + diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4099.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4099.go new file mode 100644 index 0000000000000000000000000000000000000000..edbbfebc20cf200cde9c1be5b59528035938f03d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4099.go @@ -0,0 +1,28 @@ +// errorcheck -0 -m + +//go:build !goexperiment.newinliner + +// Copyright 2013 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. + +// Check go:noescape annotations. + +package p + +// The noescape comment only applies to the next func, +// which must not have a body. + +//go:noescape + +func F1([]byte) + +func F2([]byte) + +func G() { + var buf1 [10]byte + F1(buf1[:]) + + var buf2 [10]byte // ERROR "moved to heap: buf2" + F2(buf2[:]) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41239.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41239.go new file mode 100644 index 0000000000000000000000000000000000000000..3e9ef5eb66f4f26b660d860d9a1dc8e3e4fc927e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41239.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2020 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 + +import "fmt" + +func main() { + const N = 1024 + var a [N]int + x := cap(append(a[:N-1:N], 9, 9)) + y := cap(append(a[:N:N], 9)) + if x != y { + panic(fmt.Sprintf("different capacity on append: %d vs %d", x, y)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41247.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41247.go new file mode 100644 index 0000000000000000000000000000000000000000..05889a9ce884739a5e024c86337f6931894592ef --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41247.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2020 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 p + +func f() [2]int { + return [...]int{2: 0} // ERROR "cannot use \[\.\.\.\]int{.*} \(.*type \[3\]int\)" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41440.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41440.go new file mode 100644 index 0000000000000000000000000000000000000000..0d911f0173a480ca4ceaf7b8fa725afc2030017a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41440.go @@ -0,0 +1,14 @@ +// errorcheck + +// Copyright 2020 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 p + +func f(...int) {} + +func g() { + var x []int + f(x, x...) // ERROR "have \(\[\]int, \.\.\.int\)|too many arguments" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41500.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41500.go new file mode 100644 index 0000000000000000000000000000000000000000..b0ae7cfd59f575326239970c1e48978078134f3a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41500.go @@ -0,0 +1,20 @@ +// errorcheck + +// Copyright 2020 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 p + +type s struct { + slice []int +} + +func f() { + var x *s + + _ = x == nil || len(x.slice) // ERROR "invalid operation: .+ \(operator \|\| not defined on int\)|incompatible types|mismatched types untyped bool and int" + _ = len(x.slice) || x == nil // ERROR "invalid operation: .+ \(operator \|\| not defined on int\)|incompatible types|mismatched types int and untyped bool" + _ = x == nil && len(x.slice) // ERROR "invalid operation: .+ \(operator && not defined on int\)|incompatible types|mismatched types untyped bool and int" + _ = len(x.slice) && x == nil // ERROR "invalid operation: .+ \(operator && not defined on int\)|incompatible types|mismatched types int and untyped bool" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41575.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41575.go new file mode 100644 index 0000000000000000000000000000000000000000..456873038fc891c8e2d60deebe5cbc368f96aa51 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41575.go @@ -0,0 +1,36 @@ +// errorcheck + +// Copyright 2020 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 p + +type T1 struct { // ERROR "invalid recursive type T1\n\tLINE: T1 refers to\n\tLINE+4: T2 refers to\n\tLINE: T1$|invalid recursive type" + f2 T2 +} + +type T2 struct { // GCCGO_ERROR "invalid recursive type" + f1 T1 +} + +type a b // GCCGO_ERROR "invalid recursive type" +type b c // ERROR "invalid recursive type b\n\tLINE: b refers to\n\tLINE+1: c refers to\n\tLINE: b$|invalid recursive type" +type c b // GCCGO_ERROR "invalid recursive type" + +type d e +type e f +type f f // ERROR "invalid recursive type f\n\tLINE: f refers to\n\tLINE: f$|invalid recursive type" + +type g struct { // ERROR "invalid recursive type g\n\tLINE: g refers to\n\tLINE: g$|invalid recursive type" + h struct { + g + } +} + +type w x +type x y // ERROR "invalid recursive type x\n\tLINE: x refers to\n\tLINE+1: y refers to\n\tLINE+2: z refers to\n\tLINE: x$|invalid recursive type" +type y struct{ z } // GCCGO_ERROR "invalid recursive type" +type z [10]x + +type w2 w // refer to the type loop again diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4162.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4162.go new file mode 100644 index 0000000000000000000000000000000000000000..f236bd0f6a8754b99d81a6bef32b5c98a5b4d3cc --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4162.go @@ -0,0 +1,17 @@ +// compile + +// Copyright 2013 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. + +// Issue 4162. Trailing commas now allowed in conversions. + +package p + +// All these are valid now. +var ( + _ = int(1.0,) // comma was always permitted (like function call) + _ = []byte("foo",) // was syntax error: unexpected comma + _ = chan int(nil,) // was syntax error: unexpected comma + _ = (func())(nil,) // was syntax error: unexpected comma +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41635.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41635.go new file mode 100644 index 0000000000000000000000000000000000000000..35c0034cdd40e0824f479e2fcda079b3cf638093 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41635.go @@ -0,0 +1,17 @@ +//errorcheck -0 -m -m + +// Copyright 2020 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 p + +func f() { // ERROR "" + n, m := 100, 200 + _ = make([]byte, 1<<17) // ERROR "too large for stack" "" + _ = make([]byte, 100, 1<<17) // ERROR "too large for stack" "" + _ = make([]byte, n, 1<<17) // ERROR "too large for stack" "" + + _ = make([]byte, n) // ERROR "non-constant size" "" + _ = make([]byte, 100, m) // ERROR "non-constant size" "" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4167.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4167.go new file mode 100644 index 0000000000000000000000000000000000000000..86a636f66bdee700055453bf39ddcce18bb09da1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4167.go @@ -0,0 +1,50 @@ +// run + +// Copyright 2012 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. + +// Issue 4167: inlining of a (*T).Method expression taking +// its arguments from a multiple return breaks the compiler. + +package main + +type pa []int + +type p int + +func (this *pa) func1() (v *p, c int) { + for _ = range *this { + c++ + } + v = (*p)(&c) + return +} + +func (this *pa) func2() p { + return (*p).func3(this.func1()) +} + +func (this *p) func3(f int) p { + return *this +} + +func (this *pa) func2dots() p { + return (*p).func3(this.func1()) +} + +func (this *p) func3dots(f ...int) p { + return *this +} + +func main() { + arr := make(pa, 13) + length := arr.func2() + if int(length) != len(arr) { + panic("length != len(arr)") + } + length = arr.func2dots() + if int(length) != len(arr) { + panic("length != len(arr)") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41680.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41680.go new file mode 100644 index 0000000000000000000000000000000000000000..9dfeb7d503a4b40085540ab7a6efc5fb18b6a33a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41680.go @@ -0,0 +1,21 @@ +// compile + +// Copyright 2020 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 p + +func F(s string) bool { + const m = 16 + const n = 1e5 + _ = make([]int, n) + return len(s) < n*m +} + +func G() { + const n = 1e5 + _ = make([]int, n) + f := n + var _ float64 = f +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41736.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41736.go new file mode 100644 index 0000000000000000000000000000000000000000..36f127f4fb414e11ebcaf35db32cfbe2dd1ff1ab --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41736.go @@ -0,0 +1,105 @@ +// compile + +// Copyright 2020 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 p + +type I struct { + x int64 +} + +type F struct { + x float64 +} + +type C struct { + x *complex128 +} + +type D struct { + x complex64 +} + +type A [1]*complex128 + +//go:noinline +func (i I) X() C { + cx := complex(0, float64(i.x)) + return C{&cx} +} + +//go:noinline +func (f F) X() C { + cx := complex(f.x, 0) + return C{&cx} +} + +//go:noinline +func (c C) X() C { + cx := complex(imag(*c.x), real(*c.x)) + return C{&cx} +} + +//go:noinline +func (d D) X() C { + cx := complex(float64(imag(d.x)), -float64(real(d.x))) + return C{&cx} +} + +//go:noinline +func (a A) X() C { + cx := complex(-float64(imag(*a[0])), float64(real(*a[0]))) + return C{&cx} +} + +//go:noinline +func (i I) id() I { + return i +} + +//go:noinline +func (f F) id() F { + return f +} + +//go:noinline +func (c C) id() C { + return c +} + +//go:noinline +func (d D) id() D { + return d +} + +//go:noinline +func (a A) id() A { + return a +} + +type T interface { + X() C +} + +func G(x []T) []T { + var y []T + for _, a := range x { + var v T + switch u := a.(type) { + case I: + v = u.id() + case F: + v = u.id() + case C: + v = u.id() + case D: + v = u.id() + case A: + v = u.id() + } + y = append(y, v) + } + return y +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41780.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41780.go new file mode 100644 index 0000000000000000000000000000000000000000..632c144a4871bc87795646d1d6c65f9056620fa6 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41780.go @@ -0,0 +1,39 @@ +// run + +// Copyright 2020 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. + +// Checks that conversion of CMP(x,-y) -> CMN(x,y) is only applied in correct context. + +package main + +type decimal struct { + d [8]byte // digits, big-endian representation + dp int // decimal point +} + +var powtab = []int{1, 3, 6, 9, 13, 16, 19, 23, 26} + +//go:noinline +func foo(d *decimal) int { + exp := int(d.d[1]) + if d.dp < 0 || d.dp == 0 && d.d[0] < '5' { + var n int + if -d.dp >= len(powtab) { + n = 27 + } else { + n = powtab[-d.dp] // incorrect CMP -> CMN substitution causes indexing panic. + } + exp += n + } + return exp +} + +func main() { + var d decimal + d.d[0] = '1' + if foo(&d) != 1 { + println("FAILURE (though not the one this test was written to catch)") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue41872.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue41872.go new file mode 100644 index 0000000000000000000000000000000000000000..837d61ae0a3112d360a6aabaa95a4119896e2485 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue41872.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2020 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 + +//go:noinline +func f8(x int32) bool { + return byte(x&0xc0) == 64 +} + +//go:noinline +func f16(x int32) bool { + return uint16(x&0x8040) == 64 +} + +func main() { + if !f8(64) { + panic("wanted true, got false") + } + if !f16(64) { + panic("wanted true, got false") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42032.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42032.go new file mode 100644 index 0000000000000000000000000000000000000000..eb118591019e7322d7dc30e232c0fc0d35225afe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42032.go @@ -0,0 +1,31 @@ +// run + +// Copyright 2020 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. + +//go:build cgo + +package main + +import "runtime/cgo" + +type NIH struct { + _ cgo.Incomplete +} + +type T struct { + x *NIH + p *int +} + +var y NIH +var z int + +func main() { + a := []T{{&y, &z}} + a = append(a, T{&y, &z}) + if a[1].x == nil { + panic("pointer not written") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42058a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42058a.go new file mode 100644 index 0000000000000000000000000000000000000000..722f86e1ecfdc16ec790fd4d37d33d1a28a01fdf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42058a.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2020 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 p + +var c chan [2 << 16]byte // GC_ERROR "channel element type too large" + +type T [1 << 17]byte + +var x chan T // GC_ERROR "channel element type too large" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42058b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42058b.go new file mode 100644 index 0000000000000000000000000000000000000000..71a280f96b74ba2a0687ed1495b974a1336dca21 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42058b.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2020 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 p + +var c chan [2 << 16]byte // GC_ERROR "channel element type too large" + +func f() { + _ = 42 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42075.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42075.go new file mode 100644 index 0000000000000000000000000000000000000000..af85fb281d80111a47404173259e96c11df6089c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42075.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2020 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 p + +import "unsafe" + +type T struct { // ERROR "recursive type" + x int + p unsafe.Pointer + + f T +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42076.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42076.go new file mode 100644 index 0000000000000000000000000000000000000000..ef8db2da30d68556ea8e38d1ed9344d130a61258 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42076.go @@ -0,0 +1,26 @@ +// run + +// Copyright 2020 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. + +//go:build cgo + +package main + +import ( + "reflect" + "runtime/cgo" +) + +type NIH struct { + _ cgo.Incomplete +} + +var x, y NIH + +func main() { + if reflect.DeepEqual(&x, &y) != true { + panic("should report true") + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4215.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4215.go new file mode 100644 index 0000000000000000000000000000000000000000..9f32f5b100649f87c3624045b0addbe3cd5580e8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4215.go @@ -0,0 +1,53 @@ +// errorcheck + +// Copyright 2016 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 foo() (int, int) { + return 2.3 // ERROR "not enough return values\n\thave \(number\)\n\twant \(int, int\)|not enough arguments to return" +} + +func foo2() { + return int(2), 2 // ERROR "too many (arguments to return|return values)\n\thave \(int, number\)\n\twant \(\)|return with value in function with no return type" +} + +func foo3(v int) (a, b, c, d int) { + if v >= 0 { + return 1 // ERROR "not enough return values\n\thave \(number\)\n\twant \(int, int, int, int\)|not enough arguments to return" + } + return 2, 3 // ERROR "not enough return values\n\thave \(number, number\)\n\twant \(int, int, int, int\)|not enough arguments to return" +} + +func foo4(name string) (string, int) { + switch name { + case "cow": + return "moo" // ERROR "not enough return values\n\thave \(string\)\n\twant \(string, int\)|not enough arguments to return" + case "dog": + return "dog", 10, true // ERROR "too many return values\n\thave \(string, number, bool\)\n\twant \(string, int\)|too many arguments to return" + case "fish": + return "" // ERROR "not enough return values\n\thave \(string\)\n\twant \(string, int\)|not enough arguments to return" + default: + return "lizard", 10 + } +} + +type S int +type T string +type U float64 + +func foo5() (S, T, U) { + if false { + return "" // ERROR "not enough return values\n\thave \(string\)\n\twant \(S, T, U\)|not enough arguments to return" + } else { + ptr := new(T) + return ptr // ERROR "not enough return values\n\thave \(\*T\)\n\twant \(S, T, U\)|not enough arguments to return" + } + return new(S), 12.34, 1 + 0i, 'r', true // ERROR "too many return values\n\thave \(\*S, number, number, number, bool\)\n\twant \(S, T, U\)|too many arguments to return" +} + +func foo6() (T, string) { + return "T", true, true // ERROR "too many return values\n\thave \(string, bool, bool\)\n\twant \(T, string\)|too many arguments to return" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42284.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42284.go new file mode 100644 index 0000000000000000000000000000000000000000..a1a525b8bdb583660db5e8e3cec550e940f4d802 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42284.go @@ -0,0 +1,9 @@ +// errorcheckdir -0 -m + +//go:build !goexperiment.newinliner + +// Copyright 2020 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4232.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4232.go new file mode 100644 index 0000000000000000000000000000000000000000..f49c6152e0c2b5e50f0669e09948b88cb719eafa --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4232.go @@ -0,0 +1,56 @@ +// errorcheck + +// Copyright 2013 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. + +// issue 4232 +// issue 7200 + +package p + +func f() { + var a [10]int + _ = a[-1] // ERROR "invalid array index -1|index out of bounds|must not be negative" + _ = a[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative" + _ = a[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative" + _ = a[10] // ERROR "invalid array index 10|index .*out of bounds" + _ = a[9:10] + _ = a[10:10] + _ = a[9:12] // ERROR "invalid slice index 12|index .*out of bounds" + _ = a[11:12] // ERROR "invalid slice index 11|index .*out of bounds" + _ = a[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds" + + var s []int + _ = s[-1] // ERROR "invalid slice index -1|index .*out of bounds|must not be negative" + _ = s[-1:] // ERROR "invalid slice index -1|index .*out of bounds|must not be negative" + _ = s[:-1] // ERROR "invalid slice index -1|index .*out of bounds|must not be negative" + _ = s[10] + _ = s[9:10] + _ = s[10:10] + _ = s[9:12] + _ = s[11:12] + _ = s[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds" + + const c = "foofoofoof" + _ = c[-1] // ERROR "invalid string index -1|index out of bounds|must not be negative" + _ = c[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative" + _ = c[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative" + _ = c[10] // ERROR "invalid string index 10|index .*out of bounds" + _ = c[9:10] + _ = c[10:10] + _ = c[9:12] // ERROR "invalid slice index 12|index .*out of bounds" + _ = c[11:12] // ERROR "invalid slice index 11|index .*out of bounds" + _ = c[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds" + + var t string + _ = t[-1] // ERROR "invalid string index -1|index out of bounds|must not be negative" + _ = t[-1:] // ERROR "invalid slice index -1|index out of bounds|must not be negative" + _ = t[:-1] // ERROR "invalid slice index -1|index out of bounds|must not be negative" + _ = t[10] + _ = t[9:10] + _ = t[10:10] + _ = t[9:12] + _ = t[11:12] + _ = t[1<<100 : 1<<110] // ERROR "overflows int|integer constant overflow|invalid slice index 1 << 100|index out of bounds" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42401.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42401.go new file mode 100644 index 0000000000000000000000000000000000000000..794d5b01b55d3915286293e9ed7f1c6ba6bb0d55 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42401.go @@ -0,0 +1,10 @@ +// rundir + +// Copyright 2020 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. + +// Issue 42401: linkname doesn't work correctly when a variable symbol +// is both imported (possibly through inlining) and linkname'd. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4251.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4251.go new file mode 100644 index 0000000000000000000000000000000000000000..81e3edf5e3fb6e5746279964d5c2c6b6ad292206 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4251.go @@ -0,0 +1,21 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 4251: slice with inverted range is an error. + +package p + +func F1(s []byte) []byte { + return s[2:1] // ERROR "invalid slice index|inverted slice range|invalid slice indices" +} + +func F2(a [10]byte) []byte { + return a[2:1] // ERROR "invalid slice index|inverted slice range|invalid slice indices" +} + +func F3(s string) string { + return s[2:1] // ERROR "invalid slice index|inverted slice range|invalid slice indices" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4252.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4252.go new file mode 100644 index 0000000000000000000000000000000000000000..01bcbc433192c2fb9ca7cf2e0b8ac6b0612823da --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4252.go @@ -0,0 +1,11 @@ +// rundir + +// Copyright 2012 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. + +// Issue 4252: tests that fixing the issue still allow +// builtins to be redeclared and are not corrupted +// in export data. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42568.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42568.go new file mode 100644 index 0000000000000000000000000000000000000000..834fdc58f36a911380511396a99545b9976a63f9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42568.go @@ -0,0 +1,25 @@ +// compile + +// Copyright 2020 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. + +// Ensure that late expansion correctly handles an OpIData with type interface{} + +package p + +type S struct{} + +func (S) M() {} + +type I interface { + M() +} + +func f(i I) { + o := i.(interface{}) + if _, ok := i.(*S); ok { + o = nil + } + println(o) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42587.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42587.go new file mode 100644 index 0000000000000000000000000000000000000000..d10ba979d570428ec338aea1af3ee09b5fe23494 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42587.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2020 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 p + +func f() { + var i, j int + _ = func() { + i = 32 + j = j>>i | len([]int{}) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4264.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4264.go new file mode 100644 index 0000000000000000000000000000000000000000..627393211ee8c9c5edfcc9cdc0762127363c8337 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4264.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2013 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. + +// issue 4264: reject int division by const 0 + +package main + +func main() { + var x int + var y float64 + var z complex128 + + println(x/0) // ERROR "division by zero" + println(y/0) + println(z/0) +} \ No newline at end of file diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42686.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42686.go new file mode 100644 index 0000000000000000000000000000000000000000..9f9075ca7d021b20c6d06920a15a819c5622ecfd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42686.go @@ -0,0 +1,11 @@ +// compile -goexperiment fieldtrack + +// Copyright 2020 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 p + +func a(x struct{ f int }) { _ = x.f } + +func b() { a(struct{ f int }{}) } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42703.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42703.go new file mode 100644 index 0000000000000000000000000000000000000000..15f7a915e6a79755248e82bba8b79023621ae489 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42703.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2020 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 + +var ok [2]bool + +func main() { + f()() + if !ok[0] || !ok[1] { + panic("FAIL") + } +} + +func f() func() { ok[0] = true; return g } +func g() { ok[1] = true } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42727.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42727.go new file mode 100644 index 0000000000000000000000000000000000000000..40081708b15162b9c393866b1a9a4727c4050ae2 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42727.go @@ -0,0 +1,23 @@ +// compile + +// Copyright 2020 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. + +// Ensure that late expansion correctly handles an OpLoad with type interface{} + +package p + +type iface interface { + m() +} + +type it interface{} + +type makeIface func() iface + +func f() { + var im makeIface + e := im().(it) + _ = &e +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42753.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42753.go new file mode 100644 index 0000000000000000000000000000000000000000..a998d1d3b3d92a436777489dc5c818f18c44f7a0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42753.go @@ -0,0 +1,13 @@ +// compile -d=ssa/check/on + +// Copyright 2020 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() uint32 { + s := "\x01" + x := -int32(s[0]) + return uint32(x) & 0x7fffffff +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42784.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42784.go new file mode 100644 index 0000000000000000000000000000000000000000..e2b06e9307f164853609536b570b661fa0dc5ecb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42784.go @@ -0,0 +1,26 @@ +// compile + +// Copyright 2020 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. + +// Ensure that late expansion correctly set OpLoad argument type interface{} + +package p + +type iface interface { + m() +} + +type it interface{} + +type makeIface func() iface + +func f() { + var im makeIface + e := im().(it) + g(e) +} + +//go:noinline +func g(i it) {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42790.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42790.go new file mode 100644 index 0000000000000000000000000000000000000000..d83a02247a3788758e541fa47143e423fa6426e5 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42790.go @@ -0,0 +1,9 @@ +// compile + +// Copyright 2020 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 p + +const _ = -uint(len(string(1<<32)) - len("\uFFFD")) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4283.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4283.go new file mode 100644 index 0000000000000000000000000000000000000000..fa5629b20a9f8f37f2cf79066839061872d558df --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4283.go @@ -0,0 +1,17 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 4283: nil == nil can't be done as the type is unknown. + +package p + +func F1() bool { + return nil == nil // ERROR "invalid" +} + +func F2() bool { + return nil != nil // ERROR "invalid" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42876.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42876.go new file mode 100644 index 0000000000000000000000000000000000000000..67cf4919ac547829574e59ccc45746ac6d1ea5fe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42876.go @@ -0,0 +1,18 @@ +// run + +// Copyright 2020 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 + +var x = [4]int32{-0x7fffffff, 0x7fffffff, 2, 4} + +func main() { + if x[0] > x[1] { + panic("fail 1") + } + if x[2]&x[3] < 0 { + panic("fail 2") // Fails here + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue42944.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue42944.go new file mode 100644 index 0000000000000000000000000000000000000000..bb947bc6091c4da4c12f2e46f8cf01f8847712f0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue42944.go @@ -0,0 +1,24 @@ +// errorcheck -0 -live + +// Copyright 2020 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. + +// Issue 42944: address of callee args area should only be short-lived +// and never across a call. + +package p + +type T [10]int // trigger DUFFCOPY when passing by value, so it uses the address + +func F() { + var x T + var i int + for { + x = G(i) // no autotmp live at this and next calls + H(i, x) + } +} + +func G(int) T +func H(int, T) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43099.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43099.go new file mode 100644 index 0000000000000000000000000000000000000000..16f18e5f968cba598073950afe13fa7db9299a5b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43099.go @@ -0,0 +1,34 @@ +// compile + +// Copyright 2020 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. + +// Check to make sure we don't try to constant fold a divide by zero. +// This is a tricky test, as we need a value that's not recognized as 0 +// until lowering (otherwise it gets handled in a different path). + +package p + +func f() { + var i int + var s string + for i > 0 { + _ = s[0] + i++ + } + + var c chan int + c <- 1 % i +} + +func f32() uint32 { + s := "\x00\x00\x00\x00" + c := uint32(s[0]) | uint32(s[1])<<8 | uint32(s[2])<<16 | uint32(s[3])<<24 + return 1 / c +} +func f64() uint64 { + s := "\x00\x00\x00\x00\x00\x00\x00\x00" + c := uint64(s[0]) | uint64(s[1])<<8 | uint64(s[2])<<16 | uint64(s[3])<<24 | uint64(s[4])<<32 | uint64(s[5])<<40 | uint64(s[6])<<48 | uint64(s[7])<<56 + return 1 / c +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43111.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43111.go new file mode 100644 index 0000000000000000000000000000000000000000..76d7beb084a2d97a0f60b8a9d00f5ba3e39fa9e9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43111.go @@ -0,0 +1,70 @@ +// run + +// Copyright 2020 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 + +var ch chan int +var x int + +func f() int { + close(ch) + ch = nil + return 0 +} + +func g() int { + ch = nil + x = 0 + return 0 +} + +func main() { + var nilch chan int + var v int + var ok bool + _, _ = v, ok + + ch = make(chan int) + select { + case <-ch: + case nilch <- f(): + } + + ch = make(chan int) + select { + case v = <-ch: + case nilch <- f(): + } + + ch = make(chan int) + select { + case v := <-ch: _ = v + case nilch <- f(): + } + + ch = make(chan int) + select { + case v, ok = <-ch: + case nilch <- f(): + } + + ch = make(chan int) + select { + case v, ok := <-ch: _, _ = v, ok + case nilch <- f(): + } + + ch1 := make(chan int, 1) + ch = ch1 + x = 42 + select { + case ch <- x: + case nilch <- g(): + } + if got := <-ch1; got != 42 { + panic(got) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43112.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43112.go new file mode 100644 index 0000000000000000000000000000000000000000..e36627a015550659824314989dc481bdb2afe0fb --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43112.go @@ -0,0 +1,41 @@ +// compile + +// Copyright 2020 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 p + +type Symbol interface{} + +type Value interface { + String() string +} + +type Object interface { + String() string +} + +type Scope struct { + outer *Scope + elems map[string]Object +} + +func (s *Scope) findouter(name string) (*Scope, Object) { + return s.outer.findouter(name) +} + +func (s *Scope) Resolve(name string) (sym Symbol) { + if _, obj := s.findouter(name); obj != nil { + sym = obj.(Symbol) + } + return +} + +type ScopeName struct { + scope *Scope +} + +func (n *ScopeName) Get(name string) (Value, error) { + return n.scope.Resolve(name).(Value), nil +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4313.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4313.go new file mode 100644 index 0000000000000000000000000000000000000000..2494b83b03bbdd3e0abc7961cae6586b246429f1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4313.go @@ -0,0 +1,28 @@ +// run + +// Copyright 2012 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. + +// Order of operations in select. + +package main + +func main() { + c := make(chan int, 1) + x := 0 + select { + case c <- x: // should see x = 0, not x = 42 (after makec) + case <-makec(&x): // should be evaluated only after c and x on previous line + } + y := <-c + if y != 0 { + panic(y) + } +} + +func makec(px *int) chan bool { + if false { for {} } + *px = 42 + return make(chan bool, 0) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4316.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4316.go new file mode 100644 index 0000000000000000000000000000000000000000..de9a61b497d9eea7c771c4fa55b81eee7696e4e7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4316.go @@ -0,0 +1,64 @@ +// run + +// Copyright 2012 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. + +// Issue 4316: the stack overflow check in the linker +// is confused when it encounters a split-stack function +// that needs 0 bytes of stack space. + +package main + +type Peano *Peano + +func makePeano(n int) *Peano { + if n == 0 { + return nil + } + p := Peano(makePeano(n - 1)) + return &p +} + +var countArg Peano +var countResult int + +func countPeano() { + if countArg == nil { + countResult = 0 + return + } + countArg = *countArg + countPeano() + countResult++ +} + +var s = "(())" +var pT = 0 + +func p() { + if pT >= len(s) { + return + } + if s[pT] == '(' { + pT += 1 + p() + if pT < len(s) && s[pT] == ')' { + pT += 1 + } else { + return + } + p() + } +} + +func main() { + countArg = makePeano(4096) + countPeano() + if countResult != 4096 { + println("countResult =", countResult) + panic("countResult != 4096") + } + + p() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43164.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43164.go new file mode 100644 index 0000000000000000000000000000000000000000..f21d1d5c582a72ad01d291edfae9050df45fb03f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43164.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2020 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43167.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43167.go new file mode 100644 index 0000000000000000000000000000000000000000..1d1b69af580878d4cd837d950fdd09e8b77dacdd --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43167.go @@ -0,0 +1,13 @@ +// errorcheck + +// Copyright 2020 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 p + +import . "bytes" + +var _ Buffer // use package bytes + +var Index byte // ERROR "Index redeclared.*\n\tLINE-4: previous declaration during import .bytes.|already declared|redefinition" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4323.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4323.go new file mode 100644 index 0000000000000000000000000000000000000000..f082a1fb79f109c2fe4932181e6e6ea66391c41c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4323.go @@ -0,0 +1,31 @@ +// compile + +// Copyright 2012 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. + +// Issue 4323: inlining of functions with local variables +// forgets to typecheck the declarations in the inlined copy. + +package main + +type reader struct { + C chan T +} + +type T struct{ C chan []byte } + +var r = newReader() + +func newReader() *reader { return new(reader) } + +func (r *reader) Read(n int) ([]byte, error) { + req := T{C: make(chan []byte)} + r.C <- req + return <-req.C, nil +} + +func main() { + s, err := r.Read(1) + _, _ = s, err +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4326.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4326.go new file mode 100644 index 0000000000000000000000000000000000000000..6a510f990d4ba8da16eb005e4880f7e6a77c6057 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4326.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2012 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. + +// Printing local variables in inliner shadows global names. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43292.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43292.go new file mode 100644 index 0000000000000000000000000000000000000000..02f1c69bd1a95f7c42f4e412a64ddcbe62fcc34d --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43292.go @@ -0,0 +1,59 @@ +// run + +// Copyright 2020 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 main() { + { + i := I(A{}) + + b := make(chan I, 1) + b <- B{} + + var ok bool + i, ok = <-b + _ = ok + + i.M() + } + + { + i := I(A{}) + + b := make(chan I, 1) + b <- B{} + + select { + case i = <-b: + } + + i.M() + } + + { + i := I(A{}) + + b := make(chan I, 1) + b <- B{} + + var ok bool + select { + case i, ok = <-b: + } + _ = ok + + i.M() + } +} + +type I interface{ M() int } + +type T int + +func (T) M() int { return 0 } + +type A struct{ T } +type B struct{ T } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43384.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43384.go new file mode 100644 index 0000000000000000000000000000000000000000..1bd793ba95048598543d80bdc04734ff13bfd763 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43384.go @@ -0,0 +1,124 @@ +// errorcheck + +// Copyright 2020 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 p + +type T int + +func (T) Mv() {} +func (*T) Mp() {} + +type P1 struct{ T } +type P2 struct{ *T } +type P3 *struct{ T } +type P4 *struct{ *T } + +func _() { + { + var p P1 + p.Mv() + (&p).Mv() + (*&p).Mv() + p.Mp() + (&p).Mp() + (*&p).Mp() + } + { + var p P2 + p.Mv() + (&p).Mv() + (*&p).Mv() + p.Mp() + (&p).Mp() + (*&p).Mp() + } + { + var p P3 + p.Mv() // ERROR "undefined" + (&p).Mv() // ERROR "undefined" + (*&p).Mv() // ERROR "undefined" + (**&p).Mv() + (*p).Mv() + (&*p).Mv() + p.Mp() // ERROR "undefined" + (&p).Mp() // ERROR "undefined" + (*&p).Mp() // ERROR "undefined" + (**&p).Mp() + (*p).Mp() + (&*p).Mp() + } + { + var p P4 + p.Mv() // ERROR "undefined" + (&p).Mv() // ERROR "undefined" + (*&p).Mv() // ERROR "undefined" + (**&p).Mv() + (*p).Mv() + (&*p).Mv() + p.Mp() // ERROR "undefined" + (&p).Mp() // ERROR "undefined" + (*&p).Mp() // ERROR "undefined" + (**&p).Mp() + (*p).Mp() + (&*p).Mp() + } +} + +func _() { + type P5 struct{ T } + type P6 struct{ *T } + type P7 *struct{ T } + type P8 *struct{ *T } + + { + var p P5 + p.Mv() + (&p).Mv() + (*&p).Mv() + p.Mp() + (&p).Mp() + (*&p).Mp() + } + { + var p P6 + p.Mv() + (&p).Mv() + (*&p).Mv() + p.Mp() + (&p).Mp() + (*&p).Mp() + } + { + var p P7 + p.Mv() // ERROR "undefined" + (&p).Mv() // ERROR "undefined" + (*&p).Mv() // ERROR "undefined" + (**&p).Mv() + (*p).Mv() + (&*p).Mv() + p.Mp() // ERROR "undefined" + (&p).Mp() // ERROR "undefined" + (*&p).Mp() // ERROR "undefined" + (**&p).Mp() + (*p).Mp() + (&*p).Mp() + } + { + var p P8 + p.Mv() // ERROR "undefined" + (&p).Mv() // ERROR "undefined" + (*&p).Mv() // ERROR "undefined" + (**&p).Mv() + (*p).Mv() + (&*p).Mv() + p.Mp() // ERROR "undefined" + (&p).Mp() // ERROR "undefined" + (*&p).Mp() // ERROR "undefined" + (**&p).Mp() + (*p).Mp() + (&*p).Mp() + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43428.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43428.go new file mode 100644 index 0000000000000000000000000000000000000000..773a3f3516edc429c9ab4a35751202c172222d9c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43428.go @@ -0,0 +1,25 @@ +// errorcheck + +// Copyright 2020 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 p + +import "time" + +type T int + +func (T) Mv() {} +func (*T) Mp() {} + +var _ = []int{ + T.Mv, // ERROR "cannot use T\.Mv|incompatible type" + (*T).Mv, // ERROR "cannot use \(\*T\)\.Mv|incompatible type" + (*T).Mp, // ERROR "cannot use \(\*T\)\.Mp|incompatible type" + + time.Time.GobEncode, // ERROR "cannot use time\.Time\.GobEncode|incompatible type" + (*time.Time).GobEncode, // ERROR "cannot use \(\*time\.Time\)\.GobEncode|incompatible type" + (*time.Time).GobDecode, // ERROR "cannot use \(\*time\.Time\)\.GobDecode|incompatible type" + +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43444.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43444.go new file mode 100644 index 0000000000000000000000000000000000000000..c430e1baf796bb1f4be213ddb84c831e218ebce3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43444.go @@ -0,0 +1,28 @@ +// run + +package main + +var sp = "" + +func f(name string, _ ...interface{}) int { + print(sp, name) + sp = " " + return 0 +} + +var a = f("a", x) +var b = f("b", y) +var c = f("c", z) +var d = func() int { + if false { + _ = z + } + return f("d") +}() +var e = f("e") + +var x int +var y int = 42 +var z int = func() int { return 42 }() + +func main() { println() } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43444.out b/platform/dbops/binaries/go/go/test/fixedbugs/issue43444.out new file mode 100644 index 0000000000000000000000000000000000000000..22d6a0dc691a43756330855daffb504ed1c8d822 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43444.out @@ -0,0 +1 @@ +e a b c d diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43479.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43479.go new file mode 100644 index 0000000000000000000000000000000000000000..f21d1d5c582a72ad01d291edfae9050df45fb03f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43479.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2020 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4348.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4348.go new file mode 100644 index 0000000000000000000000000000000000000000..8b1a56c1d5116a55e76a7b5ab370138482c060a7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4348.go @@ -0,0 +1,31 @@ +// skip + +// Copyright 2012 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. + +// Issue 4348. After switch to 64-bit ints the compiler generates +// illegal instructions when using large array bounds or indexes. + +// Skip. We reject symbols larger that 2GB (Issue #9862). + +package main + +// 1<<32 on a 64-bit machine, 1 otherwise. +const LARGE = ^uint(0)>>32 + 1 + +func A() int { + var a []int + return a[LARGE] +} + +var b [LARGE]int + +func B(i int) int { + return b[i] +} + +func main() { + n := A() + B(n) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43480.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43480.go new file mode 100644 index 0000000000000000000000000000000000000000..d98ad3a34e035fc1c8531db84b01faca6fbccaf3 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43480.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2020 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. + +// Issue #43480: ICE on large uint64 constants in switch cases. + +package main + +func isPow10(x uint64) bool { + switch x { + case 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19: + return true + } + return false +} + +func main() { + var x uint64 = 1 + + for { + if !isPow10(x) || isPow10(x-1) || isPow10(x+1) { + panic(x) + } + next := x * 10 + if next/10 != x { + break // overflow + } + x = next + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4353.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4353.go new file mode 100644 index 0000000000000000000000000000000000000000..6a17c461620bf63bfa7004dbed1689e3c96da97a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4353.go @@ -0,0 +1,19 @@ +// run + +// Copyright 2012 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. + +// Issue 4353. An optimizer bug in 8g triggers a runtime fault +// instead of an out of bounds panic. + +package main + +var aib [100000]int +var paib *[100000]int = &aib +var i64 int64 = 100023 + +func main() { + defer func() { recover() }() + _ = paib[i64] +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43551.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43551.go new file mode 100644 index 0000000000000000000000000000000000000000..b83fbd7af16a576c16e0fc73b84f1ca0f618b756 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43551.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43570.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43570.go new file mode 100644 index 0000000000000000000000000000000000000000..d073fde5f6b6137f46c06112b532efa0c5b96650 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43570.go @@ -0,0 +1,40 @@ +// run + +// Copyright 2021 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 + +import "fmt" + +type T [8]*int + +//go:noinline +func f(x int) T { + return T{} +} + +//go:noinline +func g(x int, t T) { + if t != (T{}) { + panic(fmt.Sprintf("bad: %v", t)) + } +} + +func main() { + const N = 10000 + var q T + func() { + for i := 0; i < N; i++ { + q = f(0) + g(0, q) + sink = make([]byte, 1024) + } + }() + // Note that the closure is a trick to get the write to q to be a + // write to a pointer that is known to be non-nil and requires + // a write barrier. +} + +var sink []byte diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4359.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4359.go new file mode 100644 index 0000000000000000000000000000000000000000..c79e9e218c98353f838a0e34e20fa5fd2c448ef0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4359.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 4359: wrong handling of broken struct fields +// causes "internal compiler error: lookdot badwidth". + +package main + +type T struct { + x T1 // ERROR "undefined" +} + +func f() { + var t *T + _ = t.x +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43619.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43619.go new file mode 100644 index 0000000000000000000000000000000000000000..3e667851a41ebe2f1a6355d114b6b97be0383c8a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43619.go @@ -0,0 +1,119 @@ +// run + +// Copyright 2021 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 + +import ( + "fmt" + "math" +) + +//go:noinline +func fcmplt(a, b float64, x uint64) uint64 { + if a < b { + x = 0 + } + return x +} + +//go:noinline +func fcmple(a, b float64, x uint64) uint64 { + if a <= b { + x = 0 + } + return x +} + +//go:noinline +func fcmpgt(a, b float64, x uint64) uint64 { + if a > b { + x = 0 + } + return x +} + +//go:noinline +func fcmpge(a, b float64, x uint64) uint64 { + if a >= b { + x = 0 + } + return x +} + +//go:noinline +func fcmpeq(a, b float64, x uint64) uint64 { + if a == b { + x = 0 + } + return x +} + +//go:noinline +func fcmpne(a, b float64, x uint64) uint64 { + if a != b { + x = 0 + } + return x +} + +func main() { + type fn func(a, b float64, x uint64) uint64 + + type testCase struct { + f fn + a, b float64 + x, want uint64 + } + NaN := math.NaN() + for _, t := range []testCase{ + {fcmplt, 1.0, 1.0, 123, 123}, + {fcmple, 1.0, 1.0, 123, 0}, + {fcmpgt, 1.0, 1.0, 123, 123}, + {fcmpge, 1.0, 1.0, 123, 0}, + {fcmpeq, 1.0, 1.0, 123, 0}, + {fcmpne, 1.0, 1.0, 123, 123}, + + {fcmplt, 1.0, 2.0, 123, 0}, + {fcmple, 1.0, 2.0, 123, 0}, + {fcmpgt, 1.0, 2.0, 123, 123}, + {fcmpge, 1.0, 2.0, 123, 123}, + {fcmpeq, 1.0, 2.0, 123, 123}, + {fcmpne, 1.0, 2.0, 123, 0}, + + {fcmplt, 2.0, 1.0, 123, 123}, + {fcmple, 2.0, 1.0, 123, 123}, + {fcmpgt, 2.0, 1.0, 123, 0}, + {fcmpge, 2.0, 1.0, 123, 0}, + {fcmpeq, 2.0, 1.0, 123, 123}, + {fcmpne, 2.0, 1.0, 123, 0}, + + {fcmplt, 1.0, NaN, 123, 123}, + {fcmple, 1.0, NaN, 123, 123}, + {fcmpgt, 1.0, NaN, 123, 123}, + {fcmpge, 1.0, NaN, 123, 123}, + {fcmpeq, 1.0, NaN, 123, 123}, + {fcmpne, 1.0, NaN, 123, 0}, + + {fcmplt, NaN, 1.0, 123, 123}, + {fcmple, NaN, 1.0, 123, 123}, + {fcmpgt, NaN, 1.0, 123, 123}, + {fcmpge, NaN, 1.0, 123, 123}, + {fcmpeq, NaN, 1.0, 123, 123}, + {fcmpne, NaN, 1.0, 123, 0}, + + {fcmplt, NaN, NaN, 123, 123}, + {fcmple, NaN, NaN, 123, 123}, + {fcmpgt, NaN, NaN, 123, 123}, + {fcmpge, NaN, NaN, 123, 123}, + {fcmpeq, NaN, NaN, 123, 123}, + {fcmpne, NaN, NaN, 123, 0}, + } { + got := t.f(t.a, t.b, t.x) + if got != t.want { + panic(fmt.Sprintf("want %v, got %v", t.want, got)) + } + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43633.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43633.go new file mode 100644 index 0000000000000000000000000000000000000000..40df49f83bef07a3f4c5d8fd4000d97484c3f224 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43633.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4365.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4365.go new file mode 100644 index 0000000000000000000000000000000000000000..09ff1bf8f7f3f48acbdfa79e008a684e8b5e30c7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4365.go @@ -0,0 +1,27 @@ +// errorcheck + +// Copyright 2015 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. + +// Test that fields hide promoted methods. +// https://golang.org/issue/4365 + +package main + +type T interface { + M() +} + +type M struct{} + +func (M) M() {} + +type Foo struct { + M +} + +func main() { + var v T = Foo{} // ERROR "has no methods|not a method|cannot use" + _ = v +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43677.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43677.go new file mode 100644 index 0000000000000000000000000000000000000000..1a68c8b8b9c5d98b088753c57ac1d70f83045900 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43677.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2021 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. + +// Issue #43677: ICE during compilation of dynamic initializers for +// composite blank variables. + +package p + +func f() *int + +var _ = [2]*int{nil, f()} + +var _ = struct{ x, y *int }{nil, f()} + +var _ interface{} = f() diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4370.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4370.go new file mode 100644 index 0000000000000000000000000000000000000000..b1d036464a89c747163ef1bc3500f0a0b5056a72 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4370.go @@ -0,0 +1,9 @@ +// compiledir + +// Copyright 2012 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. + +// Re-exporting inlined function bodies missed types in x, ok := v.(Type) + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43701.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43701.go new file mode 100644 index 0000000000000000000000000000000000000000..6e161800466bb563fc3e5d4f0de869382f85880c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43701.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2021 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 p + +func f() { + var st struct { + s string + i int16 + } + _ = func() { + var m map[int16]int + m[st.i] = 0 + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43762.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43762.go new file mode 100644 index 0000000000000000000000000000000000000000..bf950c8f524d58266ccdaaefdb1cf4bf21bea7e0 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43762.go @@ -0,0 +1,11 @@ +// errorcheck + +// Copyright 2021 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 p + +var _ = true == '\\' // ERROR "invalid operation: (cannot compare true)|(true) == '\\\\' \(mismatched types untyped bool and untyped rune\)" +var _ = true == '\'' // ERROR "invalid operation: (cannot compare true)|(true) == '\\'' \(mismatched types untyped bool and untyped rune\)" +var _ = true == '\n' // ERROR "invalid operation: (cannot compare true)|(true) == '\\n' \(mismatched types untyped bool and untyped rune\)" diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43835.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43835.go new file mode 100644 index 0000000000000000000000000000000000000000..29a519445ae5720753c842bfbccbe74eefab12c8 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43835.go @@ -0,0 +1,45 @@ +// run + +// Copyright 2021 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 main() { + if f() { + panic("FAIL") + } + if bad, _ := g(); bad { + panic("FAIL") + } + if bad, _ := h(); bad { + panic("FAIL") + } +} + +func f() (bad bool) { + defer func() { + recover() + }() + var p *int + bad, _ = true, *p + return +} + +func g() (bool, int) { + defer func() { + recover() + }() + var p *int + return true, *p +} + + +func h() (_ bool, _ int) { + defer func() { + recover() + }() + var p *int + return true, *p +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43908.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43908.go new file mode 100644 index 0000000000000000000000000000000000000000..47709eb191ecc625a267d2f91f24bdfd44fe7bbf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43908.go @@ -0,0 +1,21 @@ +// run + +// Copyright 2021 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. + +// Verify exact constant evaluation independent of +// (mathematically equivalent) expression form. + +package main + +import "fmt" + +const ulp1 = imag(1i + 2i / 3 - 5i / 3) +const ulp2 = imag(1i + complex(0, 2) / 3 - 5i / 3) + +func main() { + if ulp1 != ulp2 { + panic(fmt.Sprintf("%g != %g\n", ulp1, ulp2)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43942.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43942.go new file mode 100644 index 0000000000000000000000000000000000000000..a37d664ce4d82c62600947243b451df6893a6db9 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43942.go @@ -0,0 +1,48 @@ +// run + +// Copyright 2022 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 + +import "log" + +func main() { + defer func() { + expect(5, recover()) + }() + func() { + expect(nil, recover()) + defer func() { + defer func() { + defer func() { + defer func() { + expect(3, recover()) + }() + defer panic(3) + panic(2) + }() + defer func() { + expect(1, recover()) + }() + panic(1) + }() + }() + }() + func() { + for { + defer func() { + defer panic(5) + }() + break + } + panic(4) + }() +} + +func expect(want, have interface{}) { + if want != have { + log.Fatalf("want %v, have %v", want, have) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue43962.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue43962.go new file mode 100644 index 0000000000000000000000000000000000000000..dca4d077d5133b5fec8ddb270fa558825dd9c96c --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue43962.go @@ -0,0 +1,9 @@ +// errorcheckdir + +// Copyright 2021 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. + +// Issue 43962: Importing a package called "init" is an error. + +package ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4396a.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4396a.go new file mode 100644 index 0000000000000000000000000000000000000000..38dd4b8cfb37a5fe20be04389ebc6e0b5315e4b7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4396a.go @@ -0,0 +1,27 @@ +// run + +// Copyright 2012 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. + +// Issue 4396. Arrays of bytes are not required to be +// word aligned. 5g should use MOVB to load the address +// of s.g[0] for its nil check. +// +// This test _may_ fail on arm, but requires the host to +// trap unaligned loads. This is generally done with +// +// echo "4" > /proc/cpu/alignment + +package main + +var s = struct { + // based on lzw.decoder + a, b, c, d, e uint16 + f [4096]uint8 + g [4096]uint8 +}{} + +func main() { + s.g[0] = 1 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4396b.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4396b.go new file mode 100644 index 0000000000000000000000000000000000000000..1284870ece654139246118e3da0144e75f33926a --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4396b.go @@ -0,0 +1,29 @@ +// run + +// Copyright 2012 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. + +// This test _may_ fail on arm, but requires the host to +// trap unaligned loads. This is generally done with +// +// echo "4" > /proc/cpu/alignment + +package main + +type T struct { + U uint16 + V T2 +} + +type T2 struct { + pad [4096]byte + A, B byte +} + +var s, t = new(T), new(T) + +func main() { + var u, v *T2 = &s.V, &t.V + u.B = v.B +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4399.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4399.go new file mode 100644 index 0000000000000000000000000000000000000000..3dc212620afbd4e22652adecbd339d056fc4c3a7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4399.go @@ -0,0 +1,15 @@ +// compile + +// Copyright 2012 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. + +// Issue 4399: 8g would print "gins LEAQ nil *A". + +package main + +type A struct{ a int } + +func main() { + println(((*A)(nil)).a) +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4405.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4405.go new file mode 100644 index 0000000000000000000000000000000000000000..5ba3e1066cda55317d3f5fc918a07f6b96afccaf --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4405.go @@ -0,0 +1,15 @@ +// errorcheck + +// Copyright 2012 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 p + +const ( + _ = iota + _ // ERROR "illegal character|invalid character" + _ // ERROR "illegal character|invalid character" + _ // ERROR "illegal character|invalid character" + _ // ERROR "illegal character|invalid character" +) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44266.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44266.go new file mode 100644 index 0000000000000000000000000000000000000000..f3c1984b6fafafd66a813aceb3e9cc7a787a8ebe --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44266.go @@ -0,0 +1,23 @@ +// errorcheck + +// Copyright 2021 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 p + +import "io" + +type T1 interface { + io.Reader +} + +type T2 struct { + io.SectionReader +} + +type T3 struct { // ERROR "invalid recursive type: T3 refers to itself" + T1 + T2 + parent T3 +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4429.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4429.go new file mode 100644 index 0000000000000000000000000000000000000000..3af6f9761b3746d05083524eca69ccf5839102db --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4429.go @@ -0,0 +1,16 @@ +// errorcheck + +// Copyright 2012 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 p + +type a struct { + a int +} + +func main() { + av := a{}; + _ = *a(av); // ERROR "invalid indirect|expected pointer|cannot indirect" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44325.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44325.go new file mode 100644 index 0000000000000000000000000000000000000000..d4068385888b151eb2402c8954a8bf0e1443bbb1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44325.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44330.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44330.go new file mode 100644 index 0000000000000000000000000000000000000000..682d9c5bf30984f27c18deb5c0c9af76f77ee398 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44330.go @@ -0,0 +1,7 @@ +// rundir + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44335.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44335.go new file mode 100644 index 0000000000000000000000000000000000000000..d4068385888b151eb2402c8954a8bf0e1443bbb1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44335.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44344.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44344.go new file mode 100644 index 0000000000000000000000000000000000000000..06c4cb6cb89448ca1391d2576ced2da16640ed29 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44344.go @@ -0,0 +1,30 @@ +// compile + +// Copyright 2021 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. + +// Issue #44344: a crash in DWARF scope generation (trying to +// scope the PCs of a function that was inlined away). + +package main + +func main() { + pv := []int{3, 4, 5} + if pv[1] != 9 { + pv = append(pv, 9) + } + tryit := func() bool { + lpv := len(pv) + if lpv == 101 { + return false + } + if worst := pv[pv[1]&1]; worst != 101 { + return true + } + return false + }() + if tryit { + println(pv[0]) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44355.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44355.go new file mode 100644 index 0000000000000000000000000000000000000000..d4068385888b151eb2402c8954a8bf0e1443bbb1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44355.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44370.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44370.go new file mode 100644 index 0000000000000000000000000000000000000000..d4068385888b151eb2402c8954a8bf0e1443bbb1 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44370.go @@ -0,0 +1,7 @@ +// compiledir + +// Copyright 2021 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 ignored diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44378.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44378.go new file mode 100644 index 0000000000000000000000000000000000000000..58c88d573f20c3a6ca7c4f7df02dc0e165fda334 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44378.go @@ -0,0 +1,40 @@ +// compile + +// Copyright 2021 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. + +// This test case caused a panic in the compiler's DWARF gen code. + +// Note to future maintainers of this code: +// +// ** Do NOT run gofmt when editing this file ** +// +// In order for the buggy behavior to be triggered in the compiler, +// we need to have a the function of interest all on one gigantic line. + +package a + +type O interface{} +type IO int +type OS int + +type A struct { + x int +} + +// original versions of the two function +func (p *A) UO(o O) { + p.r(o, o) +} +func (p *A) r(o1, o2 O) { + switch x := o1.(type) { + case *IO: + p.x = int(*x) + case *OS: + p.x = int(*x + 2) + } +} + +// see note above about the importance of all this code winding up on one line. +var myverylongname0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789 int ; func (p *A) UO2(o O) { p.r2(o, o); }; func (p *A) r2(o1, o2 O) { switch x := o1.(type) { case *IO: p.x = int(*x); case *OS: p.x = int(*x + 2); } } diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44383.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44383.go new file mode 100644 index 0000000000000000000000000000000000000000..d2d57524d167d8fc520af276cde7574fa1a7ae14 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44383.go @@ -0,0 +1,18 @@ +// compile + +// Copyright 2021 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. + +// Issue 44383: gofrontend internal compiler error + +package main + +func main() { + var b1, b2 byte + f := func() int { + var m map[byte]int + return m[b1/b2] + } + f() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44432.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44432.go new file mode 100644 index 0000000000000000000000000000000000000000..8628edd03e5d2224d7b06c9866b81d980a9e7e26 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44432.go @@ -0,0 +1,13 @@ +// errorcheck -d=panic + +// Copyright 2021 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 p + +var m = map[string]int{ + "a": 1, + 1: 1, // ERROR "cannot use 1.*as.*string.*in map" + 2: 2, // ERROR "cannot use 2.*as.*string.*in map" +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue44465.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue44465.go new file mode 100644 index 0000000000000000000000000000000000000000..8cb62adaac50a28d2df8112a59568d5b69ce8962 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue44465.go @@ -0,0 +1,21 @@ +// compile -d=ssa/check/seed + +// Copyright 2021 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. + +// This code caused an internal consistency error due to a bad shortcircuit optimization. + +package p + +func f() { + var b bool + if b { + b = true + } +l: + for !b { + b = true + goto l + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4448.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4448.go new file mode 100644 index 0000000000000000000000000000000000000000..f5e47150eeafbfb4de4ac071baeaefb13de6163f --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4448.go @@ -0,0 +1,37 @@ +// run + +// Copyright 2012 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. + +// Issue 4448: 64-bit indices that are statically known +// to be bounded make 5g and 8g generate a dangling branch. + +package main + +const b26 uint64 = 0x022fdd63cc95386d + +var bitPos [64]int + +func init() { + for p := uint(0); p < 64; p++ { + bitPos[b26<

>58] = int(p) + } +} + +func MinPos(w uint64) int { + if w == 0 { + panic("bit: MinPos(0) undefined") + } + return bitPos[((w&-w)*b26)>>58] +} + +func main() { + const one = uint64(1) + for i := 0; i < 64; i++ { + if MinPos(1<> 8) + b[2] = byte(v >> 16) + b[3] = byte(v >> 24) +} + +func main() { + var b [8]byte + repro(b[:], 32) + want := [8]byte{1, 0, 0, 0, 0, 0, 0, 0} + if b != want { + panic(fmt.Sprintf("got %v, want %v\n", b, want)) + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue45258.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue45258.go new file mode 100644 index 0000000000000000000000000000000000000000..b026c0c8f539c4a62ee7b74f9f7431bf5ff08047 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue45258.go @@ -0,0 +1,28 @@ +// compile + +// Copyright 2021 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 + +type Fooer interface { + Foo() Barer +} + +type Barer interface { + Bar() +} + +type impl struct{} + +func (r *impl) Foo() Barer { + return r +} + +func (r *impl) Bar() {} + +func f1() { + var r Fooer = &impl{} + r.Foo().Bar() +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4529.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4529.go new file mode 100644 index 0000000000000000000000000000000000000000..66b96c73c73b52ae49871376d16bda0d5441fd38 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4529.go @@ -0,0 +1,33 @@ +// compile + +// Copyright 2012 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. + +// Issue 4529: escape analysis crashes on "go f(g())" +// when g has multiple returns. + +package main + +type M interface{} + +type A struct { + a string + b chan M +} + +func (a *A) I() (b <-chan M, c chan<- M) { + a.b, c = make(chan M), make(chan M) + b = a.b + + return +} + +func Init(a string, b *A, c interface { + I() (<-chan M, chan<- M) +}) { + b.a = a + go b.c(c.I()) +} + +func (a *A) c(b <-chan M, _ chan<- M) {} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue45323.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue45323.go new file mode 100644 index 0000000000000000000000000000000000000000..870d1a27f715092cca2ed4ac8d008416f239171e --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue45323.go @@ -0,0 +1,24 @@ +// compile + +// Copyright 2021 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 g() bool + +func f(y int) bool { + b, ok := true, false + if y > 1 { + ok = g() + } + if !ok { + ok = g() + b = false + } + if !ok { + return false + } + return b +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue45344.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue45344.go new file mode 100644 index 0000000000000000000000000000000000000000..70c3d8970dc770b4d23dbe25107d6fc5cb21ccf7 --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue45344.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2021 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. + +// Issue 45344: expand_calls does not handle direct interface +// typed argument well. + +package p + +type T struct { + a map[int]int +} + +func F(t T) { + G(t) +} + +func G(...interface{}) diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue45359.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue45359.go new file mode 100644 index 0000000000000000000000000000000000000000..544855676815c4c8bc0b1300e22fb5675a9c002b --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue45359.go @@ -0,0 +1,20 @@ +// compile + +// Copyright 2021 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() { + var i, j int + var b bool + i = -(i &^ i) + for 1>>uint(i) == 0 { + _ = func() { + i, b = 0, true + } + _ = b + i %= j + } +} diff --git a/platform/dbops/binaries/go/go/test/fixedbugs/issue4545.go b/platform/dbops/binaries/go/go/test/fixedbugs/issue4545.go new file mode 100644 index 0000000000000000000000000000000000000000..534ba7113afc26d80d21f8702bfb200a1bc218ea --- /dev/null +++ b/platform/dbops/binaries/go/go/test/fixedbugs/issue4545.go @@ -0,0 +1,19 @@ +// errorcheck + +// Copyright 2012 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. + +// Issue 4545: untyped constants are incorrectly coerced +// to concrete types when used in interface{} context. + +package main + +import "fmt" + +func main() { + var s uint + fmt.Println(1.0 + 1<