Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: unnecessary bounds check #64902

Closed
gnojus opened this issue Dec 30, 2023 · 2 comments
Closed

cmd/compile: unnecessary bounds check #64902

gnojus opened this issue Dec 30, 2023 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@gnojus
Copy link

gnojus commented Dec 30, 2023

go1.21.5

package p

func f(i int) {
    var t [3]int
    if i >= 0 {
        _ = t[i%len(t)]
    }
}

https://godbolt.org/z/Tda3649sv

I would assume, since i is non negative, i % len(t) should always be in bounds? But the assembly contains a panicIndex.

@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 30, 2023
@Jorropo
Copy link
Member

Jorropo commented Dec 31, 2023

I'm pretty sure this is a duplicate of #63110

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jan 9, 2024
@dmitshur dmitshur added this to the Backlog milestone Jan 9, 2024
@mknyszek mknyszek modified the milestones: Backlog, Unplanned Jan 10, 2024
@mknyszek
Copy link
Contributor

Closing as a duplicate of #63110. In triage we think it's pretty close to a duplicate, anyway.

@mknyszek mknyszek closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
None yet
Development

No branches or pull requests

6 participants