You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The issue is in gmp_int& operator = (const gmp_int& o) which calls mpz_set(m_data, o.m_data) wrongly assuming m_data is a coherent state, which is false after a move since gmp_int(gmp_int&& o) sets o.m_data[0]._mp_d = 0.
The problem seems not to appear with libstdc++ (at least my version), perhaps because std::vector does a copy rather than a move to make space for the inserted elements.
I reckon the same problem might be presents in other places in gmp.hpp. Wouldn't also be better to replace o.m_data[0]._mp_d = 0 with a proper deinitialisation ?
The text was updated successfully, but these errors were encountered:
... but m_data might be left uninitialised after a move and gmp will segfaults. Here is a test case.
Compiled with libc++
will segfaults on the insert.
The issue is in
gmp_int& operator = (const gmp_int& o)
which callsmpz_set(m_data, o.m_data)
wrongly assumingm_data
is a coherent state, which is false after a move sincegmp_int(gmp_int&& o)
setso.m_data[0]._mp_d = 0
.The problem seems not to appear with libstdc++ (at least my version), perhaps because std::vector does a copy rather than a move to make space for the inserted elements.
I reckon the same problem might be presents in other places in gmp.hpp. Wouldn't also be better to replace
o.m_data[0]._mp_d = 0
with a proper deinitialisation ?The text was updated successfully, but these errors were encountered: