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/eval.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'c/eval.c') diff --git a/c/eval.c b/c/eval.c index c004813..2f230c9 100644 --- a/c/eval.c +++ b/c/eval.c @@ -316,7 +316,8 @@ eval(struct expr *ex, enum evalmode mode) return 1; } if (ex->t == ESTRLIT && mode > EVINTCONST) return 1; - if (mode == EVSTATICINI && isptrcvt(ex->ty) && isaddrconst(ex)) { + if (mode == EVSTATICINI && (isptrcvt(ex->ty) || (isint(ex->ty) && typesize(ex->ty) == targ_primsizes[TYPTR])) + && isaddrconst(ex)) { struct expr *e = ex; while (e->t == ECAST) e = e->sub; if (e != ex) { -- cgit v1.2.3