Open Yeaseen opened 2 weeks ago
I tested this on c4go
which can correctly translate this C code
That's awesome! I knew there's some kind of bug that affects some cxgo-translated programs, but was not able to pin-point it so far. This must be one of them. Thanks for the report, I'll look into it when I can a few spare cycles :+1:
Input C code (test.c)
GCC+Clang Output with UBSan+Asan
Translated Go code
Translated go code's output
The translated go code gives a different output from what GCC and Clang give.
Root Cause
The order of operations to calculate the final variable fails in the second part.
Modification that works fine and gives the same output as gcc and clang
I modified the Go code and it worked fine.
My modification which works fine
I think the bug is how
CxGo
handles these operations and produces the output go code.