// expected: cannot convert value of type // // unsafe.Pointer is declared `__any->ptr`, so every operand type was accepted // and a value that is not a pointer silently BECAME one. The spec allows a // conversion to unsafe.Pointer from a pointer, a uintptr, unsafe.Pointer // itself, or nil - and nothing else - which is what go/types enforces on the // legacy side, so this is stage4 catching up rather than a new restriction. // // The hole was not theoretical: six sites in src/net passed a value that was // not a pointer (rounds 43/84), the type checker handed the backend a value // whose width it had guessed, and clang rejected the module with a type // mismatch that named no source line. A struct value here is the smallest // shape that used to compile. package main import ( "unsafe" ) type box struct { x int32 } func main() { var b box p := unsafe.Pointer(b) _ = p println("unreachable") }