From 0c37353e44f0feaba9d3139f8b2afb33e75c7469 Mon Sep 17 00:00:00 2001 From: Matthew Sotoudeh Date: Mon, 9 Sep 2024 23:12:55 -0400 Subject: properly handle passing type sizes with pointer arithmetic --- parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'parse.c') diff --git a/parse.c b/parse.c index 0cbabc2..547d471 100644 --- a/parse.c +++ b/parse.c @@ -2380,7 +2380,9 @@ static Node *new_add(Node *lhs, Node *rhs, Token *tok) { } // ptr + num - rhs = new_binary(ND_MUL, rhs, new_long(lhs->ty->base->size, tok), tok); + Node *base_size = new_long(lhs->ty->base->size, tok); + base_size->is_sizeof = lhs->ty->base; + rhs = new_binary(ND_MUL, rhs, base_size, tok); return new_binary(ND_ADD, lhs, rhs, tok); } -- cgit v1.2.3