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
The range loop construction @dr2chase experimented with to eliminate the out-of-bounds pointer produces exactly this sort of pattern, which in turn causes additional bounds checks to be produced.
This pattern appears in runtime.newdefer, which must be recursively go:nosplit. I'm adding a static check of this for cmd/compile, runtime: add and use go:nosplitrec compilation directive #21314. Unfortunately, while I can see that the generated call to panic here can't happen dynamically, the linker can't, so the static check fails. I can contort the code to the following, but it would be nicer if I didn't have to:
What version of Go are you using (
go version)?go version devel +1a9f27d503 Thu Jan 4 02:17:33 2018 +0000 linux/amd64
Does this issue reproduce with the latest release?
Yes.
What did you do?
What did you expect to see?
There should be no bounds check for
x[n-1].What did you see instead?
There is a bounds check.
This comes up in practice for two reasons:
The range loop construction @dr2chase experimented with to eliminate the out-of-bounds pointer produces exactly this sort of pattern, which in turn causes additional bounds checks to be produced.
This pattern appears in
runtime.newdefer, which must be recursivelygo:nosplit. I'm adding a static check of this for cmd/compile, runtime: add and use go:nosplitrec compilation directive #21314. Unfortunately, while I can see that the generated call topanichere can't happen dynamically, the linker can't, so the static check fails. I can contort the code to the following, but it would be nicer if I didn't have to:/cc @dr2chase