Skip to content

Commit

Permalink
add explicit move constructor to deal with unit test regression test-…
Browse files Browse the repository at this point in the history
…z3 algebraic on Windows/debug -

 it uses copy constructor instead of move when returning a scoped_anum in functions such as power and root.
This leads to freeing memory that gets passed as return value.

The copy constructor for scoped_numeral is also suspicious because it doesn't ensure memory ownership.
  • Loading branch information
NikolajBjorner committed Jan 20, 2024
1 parent a2993f7 commit 548be4c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/util/scoped_numeral.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class _scoped_numeral {
numeral m_num;
public:
_scoped_numeral(Manager & m):m_manager(m) {}
_scoped_numeral(_scoped_numeral const & n):m_manager(n.m_manager) { m().set(m_num, n.m_num); }
_scoped_numeral(_scoped_numeral &&) = default;
_scoped_numeral(_scoped_numeral const& n) :m_manager(n.m_manager) { m().set(m_num, n.m_num); }
_scoped_numeral(_scoped_numeral && n) noexcept: m_manager(n.m_manager) { m().swap(m_num, n.m_num); }
~_scoped_numeral() { m_manager.del(m_num); }

Manager & m() const { return m_manager; }
Expand Down

0 comments on commit 548be4c

Please sign in to comment.