From: Iain Buclaw Date: Mon, 20 Jan 2025 19:01:03 +0000 (+0100) Subject: d: Fix failing test with 32-bit compiler [PR114434] X-Git-Tag: releases/gcc-14.3.0~569 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ffa44df6768368dc516c9626ec388a3561c7644f;p=thirdparty%2Fgcc.git d: Fix failing test with 32-bit compiler [PR114434] 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. 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. (cherry picked from commit 9ab38952a2033d6d4a8e31c3c4d2ab1a25a406c6) --- diff --git a/gcc/d/expr.cc b/gcc/d/expr.cc index d055e0b4025..733302f8e2e 100644 --- a/gcc/d/expr.cc +++ b/gcc/d/expr.cc @@ -1497,7 +1497,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) @@ -2072,7 +2072,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;