C2Rust fails to transpile a valid C program using the GCC/Clang vector_size extension.
The program defines a vector type via attribute((vector_size(16))) and initializes a vector value using an initializer list. During transpilation, C2Rust skips the vector typedef due to unsupported CType::Vector, and then fails to translate main with Unknown vector init list.
C2Rust also still emits an incomplete Rust file that does not compile because main_0 is missing.
Reproducer
#include <stdint.h>
int main(void) {
uint32_t counter = 0;
uint32_t old1 = __atomic_fetch_add(&counter, 5, __ATOMIC_SEQ_CST);
uint32_t old2 = __atomic_fetch_add(&counter, 3, __ATOMIC_SEQ_CST);
typedef uint32_t v4ui __attribute__((vector_size(16)));
v4ui atomic_results = {old1, old2, counter, 0};
return 0;
}
Observed Behavior
C2Rust reports:
Transpiling test.c
error: Skipping declaration Some(Typedef { name: "v4ui", typ: CQualTypeId { qualifiers: Qualifiers { is_const: false, is_restrict: false, is_volatile: false }, ctype: CTypeId(694) }, is_implicit: false, target_dependent_macro: None }) due to error: Unsupported type Vector(CQualTypeId { qualifiers: Qualifiers { is_const: false, is_restrict: false, is_volatile: false }, ctype: CTypeId(695) }, 4)
error: Failed to translate main: Unknown vector init list: (Elaborated(CTypeId(696)), 4)
Environment
- c2rust version: v0.21.0
- platform: Ubuntu 24.04
- Rust: nightly-2022-08-08
- Clang version: 17.0.6
C2Rust fails to transpile a valid C program using the GCC/Clang
vector_sizeextension.The program defines a vector type via
attribute((vector_size(16)))and initializes a vector value using an initializer list. During transpilation, C2Rust skips the vector typedef due to unsupportedCType::Vector, and then fails to translatemainwithUnknown vector init list.C2Rust also still emits an incomplete Rust file that does not compile because
main_0is missing.Reproducer
Observed Behavior
C2Rust reports:
Environment