translate-c incorrectly lowers (expr1, bool_expr) as bool, causing assignment to int to fail #23975
Labels
bug
Observed behavior contradicts documented or intended behavior
translate-c
C to Zig source translation feature (@cImport)
Milestone
Zig Version
0.14.0-dev.3271+bd237bced
Steps to Reproduce and Observed Behavior
C code to reproduce
Translated Zig code:
Zig build failure:
Zig's
translate-c
incorrectly lowers comma expressions like(a = b, 1 && 1)
into a boolean result, even when assigned to anint
. This leads to a type mismatch error:Expected Behavior
Expected Behavior
The translated Zig code should preserve C's semantics, where logical expressions like
1 && 1
evaluate to1
(of typeint
). When used in a comma expression and assigned to anint
, the result should be treated as anint
, not abool
.I will close if this is a duplicate.
The text was updated successfully, but these errors were encountered: