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

std::sizeof is not considered constexpr #1732

Open
meheff opened this issue Nov 19, 2024 · 0 comments
Open

std::sizeof is not considered constexpr #1732

meheff opened this issue Nov 19, 2024 · 0 comments
Labels
dslx DSLX (domain specific language) implementation / front-end

Comments

@meheff
Copy link
Collaborator

meheff commented Nov 19, 2024

std::sizeof is not considered a compile time constant even though the value is known at compile time.

Repro:

import std;

fn foo(x: u32, z:u8) -> u8 {
    x[0:std::sizeof(z)]
}

Error:

std_size_not_const.x:4:20-4:23
0002: 
0003: fn foo(x: u32, z:u8) -> u8 {
0004:     x[0:std::sizeof(z)]
~~~~~~~~~~~~~~~~~~~~~~~~~^-^ TypeInferenceError: Unable to resolve slice limit to a compile-time constant.
0005: }
@meheff meheff added the dslx DSLX (domain specific language) implementation / front-end label Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
dslx DSLX (domain specific language) implementation / front-end
Projects
Status: No status
Development

No branches or pull requests

1 participant