Hi, Since the introduction of `gdc.test/runnable/test23514.d', it's exposed an incorrect compilation when adding a 64-bit constant to a link-time address. The current cast to `size_t' causes a loss of precision, which can result in incorrect compilation.
Bootstrapped and regtested on x86_64-linux-gnu/-m32, committed to mainline, and backported to releases/gcc-14. I'll also be prepping a backport to earlier release branches with included test case. Regards, Iain. --- PR d/114434 gcc/d/ChangeLog: * expr.cc (ExprVisitor::visit (PtrExp *)): Get the offset as a dinteger_t rather than a size_t. (ExprVisitor::visit (SymOffExp *)): Likewise. --- gcc/d/expr.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index 304d6bd203c..f04ec33320a 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -1499,7 +1499,7 @@ public: void visit (PtrExp *e) final override { Type *tnext = NULL; - size_t offset; + dinteger_t offset; tree result; if (e->e1->op == EXP::add) @@ -2074,7 +2074,7 @@ public: void visit (SymOffExp *e) final override { /* Build the address and offset of the symbol. */ - size_t soffset = e->isSymOffExp ()->offset; + dinteger_t soffset = e->isSymOffExp ()->offset; tree result = get_decl_tree (e->var); TREE_USED (result) = 1; -- 2.43.0