Skip to content

Commit ceaf26e

Browse files
wdvxdr1123joedian
authored andcommitted
[release-branch.go1.22] cmd/compile: mark pointer to noalg type as noalg
When the compiler writes PtrToThis field of noalg type, it generates its pointer type. Mark them as noalg to prevent put them in typelinks. Fixes #65983 Change-Id: Icbc3b18bc866f9138c7648e42dd500a80326f72b Reviewed-on: https://go-review.googlesource.com/c/go/+/567335 Reviewed-by: Matthew Dempsky <[email protected]> Auto-Submit: Keith Randall <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Keith Randall <[email protected]> (cherry picked from commit b8c76ef) Reviewed-on: https://go-review.googlesource.com/c/go/+/593876 Reviewed-by: David Chase <[email protected]>
1 parent dfe4dbf commit ceaf26e

File tree

4 files changed

+41
-0
lines changed

4 files changed

+41
-0
lines changed

src/cmd/compile/internal/types/type.go

+3
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,9 @@ func NewPtr(elem *Type) *Type {
657657
if elem.HasShape() {
658658
t.SetHasShape(true)
659659
}
660+
if elem.Noalg() {
661+
t.SetNoalg(true)
662+
}
660663
return t
661664
}
662665

test/fixedbugs/issue65957.dir/a.go

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2024 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package a
6+
7+
var s any
8+
9+
//go:noinline
10+
func F() {
11+
s = new([4]int32)
12+
}

test/fixedbugs/issue65957.dir/main.go

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2024 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
"./a"
9+
"reflect"
10+
)
11+
12+
var s = []rune{0, 1, 2, 3}
13+
14+
func main() {
15+
m := map[any]int{}
16+
k := reflect.New(reflect.ArrayOf(4, reflect.TypeOf(int32(0)))).Elem().Interface()
17+
m[k] = 1
18+
a.F()
19+
}

test/fixedbugs/issue65957.go

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// rundir
2+
3+
// Copyright 2024 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package ignored

0 commit comments

Comments
 (0)