Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Assignment to const results in a "no overload" error for operator= #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rljacobson
Copy link

On some platforms, an assignment to a const mpz_class results in a "no overload" error for operator= (assignment operator). The error is triggered when it is not true that SIZEOF_UNSIGNED_LONG == 8, e.g. on 32-bit architectures.

The context is small enough to reproduce in its entirety here:

DagNode*
SuccSymbol::makeNatDag64(uint64_t nat)
{
  DagNode* zero = zeroTerm.getDag();
#if SIZEOF_UNSIGNED_LONG == 8
  return (nat == 0) ? zero : (new S_DagNode(this, static_cast<unsigned long>(nat), zero));
#else
  //
  //	Hack for 32-bit machines.
  //
  unsigned long low = nat & 0xFFFFFFFF;
  unsigned long high = nat >> 32;
  const mpz_class number(high);
  number = (number << 32) + low;
  return (nat == 0) ? zero : (new S_DagNode(this, number, zero));
#endif
}

It looks like just a copy+paste error, because number doesn't need to be const here. Excruciating details are given in the next paragraph, which you're welcome to skip over.

The issue is in the #else preprocessor branch, where it is assumed that unsigned long is 32 bits. The "hack" is to load the value of the 64-bit parameter nat into an mpz_class number 32 bits at a time by first loading the high 32 bits into the lower 32 bits of number, shifting number left by 32, and then loading the low 32 bits of nat into the now zeroed lower 32 bits of number. These steps require at least two assignments to number, which is prohibited by the const.

The fix is to remove the const.

…ment to a `const mpz_class` results in a "no overload" error for `operator=` (assignment operator).

The fix is to remove the `const`.
@rljacobson
Copy link
Author

Out of curiosity, are there many people running Maude on 32-bit platforms?

@stevenmeker
Copy link
Collaborator

I've made your suggested change in Alpha152. I'm reluctant to accept pull requests on this repository in case it breaks my script for updating it from a private development repository.

That last bug report I have with respect to i386 was on 11/28/20 by a Debian maintainer rather than a user. People have built Maude on a Raspberry Pi but that is hardly recommended for serious use.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants