C2Rust crashes when transpiling valid C code that includes an anonymous enum inside an anonymous union within a struct, due to the lack of a field name for the enum. While this is standard-compliant C (accepted by GCC and Clang), C2Rust panics with a missing key lookup in its AST processing.
C code:
struct temp {
union {
enum {
VALUE_1,
VALUE_2
};
int int_value;
} u;
};
int main() {
struct temp b;
b.u.int_value = VALUE_2;
return 0;
}
C2Rust error:
$c2rust-transpile compile_commands.json -e -o transpiled_code --binary runner
Transpiling runner.c
thread 'main' panicked at c2rust-transpile/src/c_ast/mod.rs:653:57:
no entry found for key
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
c2rust version: C2Rust 0.20.0