-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Open
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.help wanted
Milestone
Description
Go version
go version go1.26-devel_e1a12c7 Mon Nov 17 13:45:54 2025 -0800 linux/amd64
Output of go env in your module/workspace:
Workspace is `go.godbolt.org` on `x86-64 gc (tip)` as above.What did you do?
Compile this simple example from the standard library:
func hasUpperCase(s string) bool {
for i := range s {
if 'A' <= s[i] && s[i] <= 'Z' {
return true
}
}
return false
}(As an aside: is there a reason why the above doesn't iterate over the bytes of s instead?)
What did you see happen?
Extra bounds check on s[i], even though per-spec i should still always be 0 <= i < len(s) even on invalid UTF-8.
What did you expect to see?
No extra bounds checks.
This also appears elsewhere in the standard library, such as strings.ToValidUTF8, fmt.truncateString, and time.tzsetNum.
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.Performancecompiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.help wanted
Type
Projects
Status
Todo