aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Schmidt <3405586+schmee@users.noreply.github.com>2023-02-10 14:46:29 +0100
committerGitHub <noreply@github.com>2023-02-10 15:46:29 +0200
commita5d25fabdaf7e68f375874b9bda402acaeb9545d (patch)
treeeaa62bf7c9919efbd5b8ba8d3bd467ad2462df62 /src
parentd24ebf1d12cf66665b52136a2807f97ff021d78d (diff)
downloadzig-a5d25fabdaf7e68f375874b9bda402acaeb9545d.tar.gz
zig-a5d25fabdaf7e68f375874b9bda402acaeb9545d.zip
translate_c: fix typedeffed pointer subtraction
Closes #14560.
Diffstat (limited to 'src')
-rw-r--r--src/translate_c.zig3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/translate_c.zig b/src/translate_c.zig
index a6715d161c..7fd4b93821 100644
--- a/src/translate_c.zig
+++ b/src/translate_c.zig
@@ -1748,7 +1748,8 @@ fn transBinaryOperator(
const lhs_expr = stmt.getLHS();
const lhs_qt = getExprQualType(c, lhs_expr);
const lhs_qt_translated = try transQualType(c, scope, lhs_qt, lhs_expr.getBeginLoc());
- const elem_type = lhs_qt_translated.castTag(.c_pointer).?.data.elem_type;
+ const c_pointer = getContainer(c, lhs_qt_translated).?;
+ const elem_type = c_pointer.castTag(.c_pointer).?.data.elem_type;
const sizeof = try Tag.sizeof.create(c.arena, elem_type);
const bitcast = try Tag.bit_cast.create(c.arena, .{ .lhs = ptrdiff_type, .rhs = infixOpNode });