diff options
Diffstat (limited to '')
-rw-r--r-- | test/fixedbugs/issue67141.go | 15 | ||||
-rw-r--r-- | test/fixedbugs/issue67160.go | 32 | ||||
-rw-r--r-- | test/fixedbugs/issue67255.go | 33 |
3 files changed, 80 insertions, 0 deletions
diff --git a/test/fixedbugs/issue67141.go b/test/fixedbugs/issue67141.go new file mode 100644 index 0000000..0464d1f --- /dev/null +++ b/test/fixedbugs/issue67141.go @@ -0,0 +1,15 @@ +// errorcheck -lang=go1.22 + +//go:build go1.21 + +// We need a line directive before the package clause, +// but don't change file name or position so that the +// error message appears at the right place. + +//line issue67141.go:10 +package p + +func _() { + for range 10 { // ERROR "cannot range over 10" + } +} diff --git a/test/fixedbugs/issue67160.go b/test/fixedbugs/issue67160.go new file mode 100644 index 0000000..be45a61 --- /dev/null +++ b/test/fixedbugs/issue67160.go @@ -0,0 +1,32 @@ +// run + +// Copyright 2024 The Go 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 that we don't try using larger loads for +// generated equality functions on architectures that can't do +// unaligned loads. + +package main + +// T has a big field that wants to be compared with larger loads/stores. +// T is "special" because of the unnamed field, so it needs a generated equality function. +// T is an odd number of bytes in size and has alignment 1. +type T struct { + src [8]byte + _ byte +} + +// U contains 8 copies of T, each at a different %8 alignment. +type U [8]T + +//go:noinline +func f(x, y *U) bool { + return *x == *y +} + +func main() { + var a U + _ = f(&a, &a) +} diff --git a/test/fixedbugs/issue67255.go b/test/fixedbugs/issue67255.go new file mode 100644 index 0000000..7ca7a23 --- /dev/null +++ b/test/fixedbugs/issue67255.go @@ -0,0 +1,33 @@ +// run + +// Copyright 2024 The Go Authors. 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 zero int + +var sink any + +func main() { + var objs [][]*byte + for i := 10; i < 200; i++ { + // The objects we're allocating here are pointer-ful. Some will + // max out their size class, which are the ones we want. + // We also allocate from small to large, so that the object which + // maxes out its size class is the last one allocated in that class. + // This allocation pattern leaves the next object in the class + // unallocated, which we need to reproduce the bug. + objs = append(objs, make([]*byte, i)) + } + sink = objs // force heap allocation + + // Bug will happen as soon as the write barrier turns on. + for range 10000 { + sink = make([]*byte, 1024) + for _, s := range objs { + s = append(s, make([]*byte, zero)...) + } + } +} |