You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
c2rust transpiler demonstrates an inability to handle struct initializations where the fields are initialized with expressions that involve operations, including arithmetic, increments, and decrements. This limitation affects the successful transpilation of typical C code patterns where struct fields are dynamically initialized using various expressions.
Source C Code
typedefstruct {
inta;
} Data;
intmain() {
intp=10;
DatamyDataInc= {p++}; // error here at Post-increment DatamyDataDec= {p--}; // error here at Post-decrementDatamyDataAdd= {p+4}; // error here at Arithmetic additionDatamyDataMinus= {p-4}; // error here at Arithmetic subtractionreturn0;
}
Transpilation Error
Attempting to transpile the above code using c2rust results in an error message that suggests a fundamental handling issue with expressions in struct field initialization:
c2rust v0.18.0 shows the following error:
$ c2rust-transpile compile_commands.json -e -o transpiled_code --binary runner
Transpiling runner.c
error: Failed to translate main: Expected no statements in field expression
This error reveals that c2rust expects field initializations in struct to be straightforward without involving any operations or statements.
Expected Behavior
c2rust should ideally handle all forms of valid expressions used in struct field initializations, reflecting the diverse and dynamic initialization practices in C programming.
The text was updated successfully, but these errors were encountered:
Description
c2rust
transpiler demonstrates an inability to handle struct initializations where the fields are initialized with expressions that involve operations, including arithmetic, increments, and decrements. This limitation affects the successful transpilation of typical C code patterns where struct fields are dynamically initialized using various expressions.Source C Code
Transpilation Error
Attempting to transpile the above code using
c2rust
results in an error message that suggests a fundamental handling issue with expressions in struct field initialization:c2rust v0.18.0
shows the following error:$ c2rust-transpile compile_commands.json -e -o transpiled_code --binary runner Transpiling runner.c error: Failed to translate main: Expected no statements in field expression
This error reveals that c2rust expects field initializations in
struct
to be straightforward without involving any operations or statements.Expected Behavior
c2rust
should ideally handle all forms of valid expressions used in struct field initializations, reflecting the diverse and dynamic initialization practices in C programming.The text was updated successfully, but these errors were encountered: