'Why doesn't dereferencing a nil pointer in unsafe.Sizeof() cause a panic?
https://go.dev/play/p/X_BH4qGgXHJ
package main
import (
"fmt"
"unsafe"
)
func main() {
var i *int
fmt.Println(unsafe.Sizeof(*i)) // dereference of null pointer i
}
Why doesn't this code
unsafe.Sizeof(*i)
cause a runtime panic?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
