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

const in array types causes rustc error #1334

Open
tjhance opened this issue Nov 5, 2024 · 1 comment
Open

const in array types causes rustc error #1334

tjhance opened this issue Nov 5, 2024 · 1 comment
Assignees
Labels
blocking an issue that blocks progress of a Verus project

Comments

@tjhance
Copy link
Collaborator

tjhance commented Nov 5, 2024

Reported on zulip:

const TEST: usize = 4;

pub fn get_array() -> [u8; TEST] {
    return [0; TEST]
}

gives this error:

error[E0080]: it is undefined behavior to use this value
 --> txz.rs:4:28
  |
4 | pub fn get_array() -> [u8; TEST] {
  |                            ^^^^ constructing invalid value: encountered uninitialized memory, but expected an integer

I'm pretty sure this has to do with the override of providers.eval_to_const_value_raw in the recent 1.79.0 upgrade.

@tjhance tjhance changed the title const in array literals causes rustc error const in array types causes rustc error Nov 5, 2024
@utaal utaal self-assigned this Nov 7, 2024
@tjhance
Copy link
Collaborator Author

tjhance commented Nov 12, 2024

This is also problematic because the issue isn't restricted to the verus! macro, so it's problematic for crates with lots of external code. Currently a blocking issue for the rustlib project.

@tjhance tjhance added the blocking an issue that blocks progress of a Verus project label Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocking an issue that blocks progress of a Verus project
Projects
None yet
Development

No branches or pull requests

2 participants