Skip to content

Commit 1ab8273

Browse files
committed
cmd/compile: ensure size is computed for shape types
Fixes #50993 Change-Id: I5f1bf5a8375c3da3203083b11de26962523ccb36 Reviewed-on: https://go-review.googlesource.com/c/go/+/382874 Trust: Keith Randall <[email protected]> Run-TryBot: Keith Randall <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Dan Scales <[email protected]> Trust: Dan Scales <[email protected]>
1 parent 7f9494c commit 1ab8273

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/cmd/compile/internal/typecheck/subr.go

+1
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,7 @@ func Shapify(t *types.Type, index int, tparam *types.Type) *types.Type {
14801480
s.SetUnderlying(u)
14811481
s.SetIsShape(true)
14821482
s.SetHasShape(true)
1483+
types.CalcSize(s)
14831484
name.SetType(s)
14841485
name.SetTypecheck(1)
14851486
submap[u] = s

test/typeparam/issue50993.go

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// compile -d=checkptr
2+
3+
// Copyright 2022 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 main
8+
9+
import (
10+
"sync/atomic"
11+
"unsafe"
12+
)
13+
14+
type Node[T any] struct {
15+
Next *Node[T]
16+
// Prev *Node[T]
17+
}
18+
19+
func LoadPointer[T any](addr **T) (val *T) {
20+
return (*T)(
21+
atomic.LoadPointer(
22+
(*unsafe.Pointer)(unsafe.Pointer(addr)),
23+
))
24+
}
25+
26+
func (q *Node[T]) Pop() {
27+
var tail, head *Node[T]
28+
if head == LoadPointer(&tail) {
29+
}
30+
}
31+
32+
func main() {
33+
ch := Node[uint64]{}
34+
ch.Pop()
35+
}

0 commit comments

Comments
 (0)