]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
d: Fix failing test with 32-bit compiler [PR114434]
authorIain Buclaw <ibuclaw@gdcproject.org>
Mon, 20 Jan 2025 19:01:03 +0000 (20:01 +0100)
committerIain Buclaw <ibuclaw@gdcproject.org>
Mon, 20 Jan 2025 19:20:37 +0000 (20:20 +0100)
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.

gcc/d/expr.cc

index 304d6bd203c5898cb6ac9b6121d415be331796d8..f04ec33320a480d39c334724228fa418505c69d2 100644 (file)
@@ -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;