diff options
| author | Devin J. Pohly <djpohly@gmail.com> | 2024-06-13 23:49:29 -0500 |
|---|---|---|
| committer | Isaac Freund <mail@isaacfreund.com> | 2024-06-15 18:19:33 +0200 |
| commit | ffb1a6d9a75a7c8804c0e9db0e23ac54265f447c (patch) | |
| tree | b305e12bbf1ebbb64e1f9b3289e648c78404da8e /src | |
| parent | 7829be6ee07aba6574fa5035c3d33023b3e23de7 (diff) | |
| download | zig-ffb1a6d9a75a7c8804c0e9db0e23ac54265f447c.tar.gz zig-ffb1a6d9a75a7c8804c0e9db0e23ac54265f447c.zip | |
translate-c: fix translation of "ptr += uint"
The right-hand side was incorrectly cast to a pointer, since only signed
ints were being interpreted correctly as pointer arithmetic.
Fixes #20285.
Diffstat (limited to 'src')
| -rw-r--r-- | src/translate_c.zig | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/translate_c.zig b/src/translate_c.zig index 148b73955b..8778310751 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -3824,8 +3824,9 @@ fn transCreateCompoundAssign( const lhs_qt = getExprQualType(c, lhs); const rhs_qt = getExprQualType(c, rhs); const is_signed = cIsSignedInteger(lhs_qt); + const is_ptr_arithmetic = qualTypeIsPtr(lhs_qt) and cIsInteger(rhs_qt); const is_ptr_op_signed = qualTypeIsPtr(lhs_qt) and cIsSignedInteger(rhs_qt); - const requires_cast = !lhs_qt.eq(rhs_qt) and !is_ptr_op_signed; + const requires_cast = !lhs_qt.eq(rhs_qt) and !is_ptr_arithmetic; if (used == .unused) { // common case |
