boostorg / multiprecision

Boost.Multiprecision
Boost Software License 1.0
194 stars 111 forks source link

undefined-behavior /include/boost/multiprecision/cpp_int/import_export.hpp #556

Closed Wayonb closed 1 year ago

Wayonb commented 1 year ago

While running our unit tests with UndefinedBehaviorSanitizer, we hit an error condition. The error did not seems to be related to our code so I took first example and it reproduce the same error. https://www.boost.org/doc/libs/1_80_0/libs/multiprecision/doc/html/boost_multiprecision/tut/import_export.html#boost_multiprecision.tut.import_export.examples

Is this is a known issue or am I missing something?

/mybuild/include/boost/multiprecision/cpp_int/import_export.hpp:112:54: runtime error: implicit conversion from type 'difference_type' (aka 'long') of value -8 (64-bit, signed) to type 'unsigned long' changed the value to 18446744073709551608 (64-bit, unsigned)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mybuild/include/boost/multiprecision/cpp_int/import_export.hpp:112:54 in 
/mybuild/include/boost/multiprecision/cpp_int/import_export.hpp:112:42: runtime error: implicit conversion from type 'unsigned long' of value 18446744073709551608 (64-bit, unsigned) to type 'difference_type' (aka 'long') changed the value to -8 (64-bit, signed)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior /mybuild/include/boost/multiprecision/cpp_int/import_export.hpp:112:42 in 
mborland commented 1 year ago

What version of boost are you using? The docs link is 1.80, and there was a fix applied in 1.81. On current develop with GCC-13.1.1 on Fedora 38 I can not replicate the UBSAN error with the linked example.

Wayonb commented 1 year ago

What version of boost are you using? The docs link is 1.80, and there was a fix applied in 1.81. On current develop with GCC-13.1.1 on Fedora 38 I can not replicate the UBSAN error with the linked example.

@mborland Thanks for the quick reply. We had another issues with boost 1.81 which prevented us from upgrade. I see boost 1.82 is also release but will try upgrading after Conan package is released.

ckormanyos commented 1 year ago

will try upgrading after Conan package is released

Hi @Wayonb I'm going through our Multiprecision issues. Do you have an updated report for this? Is the issue still present/known/active?

Wayonb commented 1 year ago

@ckormanyos I will close until we have time to update. Thanks.