-
Notifications
You must be signed in to change notification settings - Fork 293
Open
Description
C2Rust fails to transpile a valid C program using the GCC/Clang vector_size extension when indexing a vector value.
The program defines a vector type via attribute((vector_size(16))), initializes a vector value, and then accesses one element with vec[0]. During transpilation, C2Rust skips the vector typedef due to unsupported CType::Vector, and then fails to translate main with Attempting to index a vector type.
Reproducer
#include <stdint.h>
#include <stdio.h>
int main(void) {
typedef float v4sf __attribute__((vector_size(16)));
v4sf vec = { 5.0f, 6.0f, 7.0f, 8.0f };
printf("%g\n", vec[0]);
return 0;
}
Observed Behavior
C2Rust reports:
Transpiling test.c
error: Skipping declaration Some(Typedef { name: "v4sf", typ: CQualTypeId { qualifiers: Qualifiers { is_const: false, is_restrict: false, is_volatile: false }, ctype: CTypeId(700) }, 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(466) }, 4)
error: Failed to translate main: Attempting to index a vector type
Environment
- c2rust version: v0.21.0
- platform: Ubuntu 24.04
- Rust: nightly-2022-08-08
- Clang version: 17.0.6
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels