cmd/compile: unnecessary nil pointer check #40108
Open
Labels
Milestone
Comments
If |
The Go spec doesn't currently prescribe whether the dereference or bounds-check happens first. So as long as users aren't confused by the change in error message, this seems fine to me. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code generates a nil pointer check on
p
.We don't really need a nil pointer check, as the index is bounded by the bounds check.
We can subsume the nil pointer check into the load.
This would require the nil pointer pass to know that indexes are bounded for indexed loads, so it can prove that the load still occurs in the zero page even with the largest possible index.
Maybe we need to keep some information from the prove pass around somehow?
The text was updated successfully, but these errors were encountered: