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

Missing compile time check for bounds of a slice of a slice with compile time constants #4684

Open
paolodelfino opened this issue Jan 13, 2025 · 0 comments

Comments

@paolodelfino
Copy link

Context

Odin: dev-2025-01-nightly:2aae4cf
OS: Windows 10 Professional (version: 22H2), build 19045.5247
Backend: LLVM 18.1.8

Expected Behavior

a := []i32{4, 5, 6}
fmt.println(a[5:])
// Ensuring is a slice
info := type_info_of(typeid_of(type_of(a))) // []i32
size_of(a) // 16 which is 8 for the pointer and 8 for the len
size_of([3]i32) // 12 which is 4 for one element * 3 for the number of elements

Given that a is a slice of a FIXED ARRAY and I'm taking a slice to a certain bounds with COMPILE TIME CONSTANTS, why isn't the bounds check done at compile time rather than exclusively at runtime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant