From 6c3f1593e953393f4b9329a0c47c5af0a587c8c9 Mon Sep 17 00:00:00 2001 From: lemon Date: Wed, 25 Feb 2026 17:57:39 +0100 Subject: c: allow casting of symbol address to intptr_t in static initializers --- c/c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'c/c.c') diff --git a/c/c.c b/c/c.c index 019fb15..2c78937 100644 --- a/c/c.c +++ b/c/c.c @@ -1418,7 +1418,8 @@ expr2reloc(union ref *psym, const struct expr *ex) { if (ex->t == EADDROF && globsym(psym, ex->sub)) { return 0; - } else if (isptrcvt(ex->ty) && globsym(psym, ex)) { + } else if ((isptrcvt(ex->ty) || (isint(ex->ty) && typesize(ex->ty) == targ_primsizes[TYPTR])) + && globsym(psym, ex)) { return 0; } else if (ex->t == EADDROF && ex->sub->t == EGETF && globsym(psym, ex->sub->sub)) { return ex->sub->fld.off; -- cgit v1.2.3