C2Rust crashes when translating a valid C program that uses C99 complex numbers and the imaginary unit macro I from <complex.h>.
The translator first reports an invalid exported Clang AST involving a TagUnaryOperator node from the macro expansion I, then panics with no entry found for key.
Even if C2Rust does not fully support complex floating-point types or the I macro, it should emit a graceful unsupported-feature diagnostic instead of panicking.
To Reproduce
#include <complex.h>
int main(void) {
double complex z = 1.0 + 2.0 * I;
return 0;
}
Run C2Rust translation:
Observed Behavior
Transpiling test.c
warning: Missing child 96774104899376 of node AstNode { tag: TagUnaryOperator, children: [Some(96774104899376)], loc: SrcSpan { fileid: 5, begin_line: 4, begin_column: 36, end_line: 4, end_column: 36 }, type_id: Some(96774104846208), rvalue: RValue, macro_expansions: [], macro_expansion_text: Some("I"), extras: [Text("__extension__"), Bool(false)] }
Exported Clang AST was invalid. Check warnings above for unimplemented features.
--> test.c:4:36
[-Wclang-ast]
thread 'main' panicked at 'no entry found for key', c2rust-transpile/src/c_ast/iterators.rs:332:69
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Expected Behavior
C2Rust should not panic. It should either:
- translate the C99 complex expression correctly, or
- report that complex floating-point expressions or the I macro are unsupported, without crashing during AST traversal.
Environment
- c2rust version: v0.21.0
- platform: Ubuntu 24.04
- Rust: nightly-2022-08-08
- Clang version: 17.0.6
C2Rust crashes when translating a valid C program that uses C99 complex numbers and the imaginary unit macro
Ifrom<complex.h>.The translator first reports an invalid exported Clang AST involving a
TagUnaryOperatornode from the macro expansionI, then panics withno entry found for key.Even if C2Rust does not fully support complex floating-point types or the
Imacro, it should emit a graceful unsupported-feature diagnostic instead of panicking.To Reproduce
Run C2Rust translation:
Observed Behavior
Expected Behavior
C2Rust should not panic. It should either:
Environment