Join GitHub today
cmd/compile: Program should arguably panic, but doesn't #39122
What version of Go are you using (
That's not a legal slice. The compiler/runtime assume that a slice with a nonzero length has a non-nil data pointer.
Using unsafe you can always put the system into a weird state it wasn't prepared for. For example, a string with a negative length. Users of unsafe need to be prepared for all kinds of restrictions (that aren't specified anywhere).
I'm going to close this issue. I don't see anything actionable here. Unless you are proposing we remove optimizations to handle weird unsafe cases like this?
The spec makes no promises about non-zero faulting pointers. We currently crash (not panic) if we dereference one.