mirror of
https://github.com/golang/go
synced 2024-11-25 13:27:57 -07:00
527ace0ffa
For unsafe.{Alignof,Offsetof,Sizeof}, subster will transform them them to OLITERAL nodes, and discard their arguments. However, any closure in their children nodes were already processed and added to declaration queue. Thus, we lack of information for generating instantiation for the closure. To fix it, just skip substituting the closures if we are going to edit the children nodes of unsafe builtins. Fixes #53390 Change-Id: Ia815cd05af9dc0491f10faac4399f378ac53dec6 Reviewed-on: https://go-review.googlesource.com/c/go/+/412794 Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
21 lines
334 B
Go
21 lines
334 B
Go
// 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.
|
|
|
|
package p
|
|
|
|
import "unsafe"
|
|
|
|
func F[T any](v T) uintptr {
|
|
return unsafe.Alignof(func() T {
|
|
func(any) {}(struct{ _ T }{})
|
|
return v
|
|
}())
|
|
}
|
|
|
|
func f() {
|
|
F(0)
|
|
}
|