Local variables naming collision when using translate-c with __builtin_convertvector #23999
Labels
bug
Observed behavior contradicts documented or intended behavior
translate-c
C to Zig source translation feature (@cImport)
Milestone
Zig Version
master
Steps to Reproduce and Observed Behavior
Create a
lib.c
file with following content:Run
zig translate-c lib.c
. The function will transform into the following zig code:When trying to compile this code (either directly, or by just c-importing it into zig code) we get an error:
Expected Behavior
The C code should be translated without naming collisions. Apparently something is not fully working with how compiler generates unique temporary names.
For reference: https://clang.llvm.org/docs/LanguageExtensions.html#builtin-convertvector
I am also a little bit surprised by another thing. Part
const tmp =
is mentioned three times in generated code. But the error is produce for collision between first and third mentions. Why then the second mention is not shadowing the first one.Question: I wrote a simple test in
test/cases/translate_c/
to reproduce the issue (with faulty zig code output). Should I create a pull request so once the issue is fixed we can alter the test and ensure that the output is good now?Submitting a bug here to ensure this is not a known issue.
The text was updated successfully, but these errors were encountered: