Skip to content

Commit

Permalink
d: Fix failing test with 32-bit compiler [PR114434]
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ibuclaw committed Jan 20, 2025
1 parent 0d1e62b commit 9ab3895
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions gcc/d/expr.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ class ExprVisitor : public Visitor
void visit (PtrExp *e) final override
{
Type *tnext = NULL;
size_t offset;
dinteger_t offset;
tree result;

if (e->e1->op == EXP::add)
Expand Down Expand Up @@ -2074,7 +2074,7 @@ class ExprVisitor : public Visitor
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;

Expand Down

0 comments on commit 9ab3895

Please sign in to comment.