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

Matching enums generates unused variables #128

Closed
franziskuskiefer opened this issue Jan 8, 2025 · 3 comments
Closed

Matching enums generates unused variables #128

franziskuskiefer opened this issue Jan 8, 2025 · 3 comments

Comments

@franziskuskiefer
Copy link
Collaborator

In different cases where enums are used, unused variables are generated in C.
Here is one example I could isolate.

enum E {
    A = 1,
    B = 2,
}

fn fun_a(_x: &[u8]) {}
fn fun_b(_x: &[u8]) {}

fn use_enum(e: E, x: &[u8]) {
    match e {
        E::A => fun_a(x),
        E::B => fun_b(x),
    }
}

This generates the following C code.
Note that the function calls are dropped because they don't do anything. When they do something, they are called. But the uu____0 sticks around.

void eurydice_tests_use_enum(eurydice_tests_E e, Eurydice_slice x)
{
  void *uu____0 = (void *)0U;
  if (!(e == eurydice_tests_E_A))
  {
    return;
  }
}
@msprotz
Copy link
Contributor

msprotz commented Jan 10, 2025

this is an easy fix I'm running regressions on everest right now -- just need to inline away variables that are internal and that are trivially values

@msprotz
Copy link
Contributor

msprotz commented Jan 10, 2025

the easy fix breaks HACL*

@msprotz
Copy link
Contributor

msprotz commented Jan 10, 2025

FStarLang/karamel#522

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

2 participants