]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: emit definition of 'any' when compiling runtime
authorThan McIntosh <thanm@google.com>
Tue, 16 Nov 2021 23:44:08 +0000 (18:44 -0500)
committerThan McIntosh <thanm@google.com>
Wed, 17 Nov 2021 01:56:19 +0000 (01:56 +0000)
Include the predefined type 'any' in the list of other important
predefined types that are emitted when compiling the runtime package
(uintptr, string, etc).

Fixes #49619.

Change-Id: I4a851ba2f302fbc3a425e65daa325c6bf83659da
Reviewed-on: https://go-review.googlesource.com/c/go/+/364377
Trust: Than McIntosh <thanm@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
src/cmd/compile/internal/reflectdata/reflect.go
test/fixedbugs/issue49619.go [new file with mode: 0644]

index 4e20dbf29ea8cc9e0b3dabd3739c429f19938972..e22fabb4108a81d9ad32b84bdae0a7dfcf0d6868 100644 (file)
@@ -1384,6 +1384,7 @@ func WriteBasicTypes() {
                }
                writeType(types.NewPtr(types.Types[types.TSTRING]))
                writeType(types.NewPtr(types.Types[types.TUNSAFEPTR]))
+               writeType(types.AnyType)
 
                // emit type structs for error and func(error) string.
                // The latter is the type of an auto-generated wrapper.
diff --git a/test/fixedbugs/issue49619.go b/test/fixedbugs/issue49619.go
new file mode 100644 (file)
index 0000000..c9f3cbc
--- /dev/null
@@ -0,0 +1,19 @@
+// build
+
+// 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 testcase caused a linker crash in DWARF generation.
+
+package main
+
+//go:noinline
+func f() any {
+       var a []any
+       return a[0]
+}
+
+func main() {
+       f()
+}