Skip to content

Matching enums generates unused variables #128

@franziskuskiefer

Description

@franziskuskiefer

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;
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions