mirror of
https://github.com/golang/go
synced 2024-11-17 22:24:47 -07:00
8f854244ad
Make sure the argument to memmove is of pointer type before we try to get the element type. This has been noticed for code that uses unsafe+linkname so it can call runtime.memmove. Probably not the best thing to allow, but the code is out there and we'd rather not break it unnecessarily. Fixes #30061 Change-Id: I334a8453f2e293959fd742044c43fbe93f0b3d31 Reviewed-on: https://go-review.googlesource.com/c/160826 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
21 lines
465 B
Go
21 lines
465 B
Go
// compile
|
|
|
|
// Copyright 2019 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.
|
|
|
|
// Make sure we can linkname to memmove with an unsafe.Pointer argument.
|
|
|
|
package p
|
|
|
|
import "unsafe"
|
|
|
|
//go:linkname memmove runtime.memmove
|
|
func memmove(to, from unsafe.Pointer, n uintptr)
|
|
|
|
var V1, V2 int
|
|
|
|
func F() {
|
|
memmove(unsafe.Pointer(&V1), unsafe.Pointer(&V2), unsafe.Sizeof(int(0)))
|
|
}
|