-
Notifications
You must be signed in to change notification settings - Fork 18.3k
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.24.1 linux/amd64
Output of go env
in your module/workspace:
-
What did you do?
package pkg
import "slices"
func Foo() {
var xs []int
xs = slices.Grow(xs, 4)[:len(xs)+4]
}
What did you see happen?
Slicing after growing inserts a check for the capacity and a conditional call to runtime.panicSliceAcap
What did you expect to see?
The compiler should be able to tell that we just guaranteed that the slice's capacity is at least len(xs)+4
and shouldn't insert another check.
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