You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I like the current behavior, as it allows the following to work which lets you get sizes of arbitrary types given their names:
unsafe.Sizeof(*(*uint8)(nil))
See https://play.golang.org/p/MeFfDzoGpxo, my reading of "compile-time constant expressions of" implied that is wouldn't evaluate the expression, leading me to the above construct. I'm using this in some generated code now.
At least in cmd/compile, unsafe.Alignof, unsafe.Offsetof, and unsafe.Sizeof do not evaluate their arguments: http://play.golang.org/p/4QE3mVrFaS
Although unsurprising and consistent with C/C++, the Go spec doesn't mention this. It does say
but I don't think that's necessarily mutually exclusive with evaluating the argument expression.
The text was updated successfully, but these errors were encountered: