debcrafters-packages team mailing list archive
-
debcrafters-packages team
-
Mailing list archive
-
Message #06827
[Bug 2122352] Re: Noble/1.83: compile error re: undefined behavior (fix available)
In case GitHub goes away, minimal repro is:
#include <boost/multiprecision/cpp_int.hpp>
using BigInt = boost::multiprecision::cpp_int;
BigInt calcm(unsigned ls) {
return BigInt(1) << ls;
}
docker run -it --rm -v $(pwd):/data ubuntu:24.04
apt update
apt -y install libboost-dev g++
cd /data
g++ -O0 -fdiagnostics-color=always -Wall -Wextra -Wno-overloaded-virtual \
-Wno-deprecated -Wno-deprecated-declarations -pedantic -O3 -DNDEBUG \
-Wall -Wextra -Wno-overloaded-virtual -Wno-deprecated \
-Wno-deprecated-declarations -pedantic -Werror -Wall -Wextra -Wswitch-enum \
-std=gnu++20 \
-c -o repro repro.cpp
Failure mode:
inlined from 'BigInt calcm(size_t, size_t)' at repro.cpp:46:24,
inlined from 'void f(S*, S*)' at repro.cpp:51:36:
/usr/include/boost/multiprecision/cpp_int/bitwise.hpp:441:26: error: iteration 2305843009213693951 invokes undefined behavior [-Werror=aggressive-loop-optimizations]
441 | pr[rs - 1 - i] = pr[rs - 1 - i - offset] << shift;
| ~~^
/usr/include/boost/multiprecision/cpp_int/bitwise.hpp:439:18: note: within this loop
439 | for (; rs - i >= 2 + offset; ++i)
| ~~~~~~~^~~~~~~~~~~~~
Fix:
include/boost/multiprecision/cpp_int/bitwise.hpp
@@ -436,7 +436,7 @@ inline BOOST_MP_CXX14_CONSTEXPR void left_shift_generic(Int& result, double_limb
++i;
}
}
- for (; rs - i >= static_cast<std::size_t>(static_cast<std::size_t>(2u) + offset); ++i)
+ for (; static_cast<std::ptrdiff_t>(static_cast<std::ptrdiff_t>(rs) - static_cast<std::ptrdiff_t>(i)) >= static_cast<std::ptrdiff_t>(2 + static_cast<std::ptrdiff_t>(offset)); ++i)
--
You received this bug notification because you are a member of
Debcrafters packages, which is subscribed to boost-defaults in Ubuntu.
https://bugs.launchpad.net/bugs/2122352
Title:
Noble/1.83: compile error re: undefined behavior (fix available)
Status in boost-defaults package in Ubuntu:
New
Bug description:
https://github.com/boostorg/multiprecision/issues/733
Using a specific simple Boost feature yields a compile error re:
undefined behavior. See the GitHub bug for full details and a simple
patch that solves the issue. Is it possible to rebuild the Ubuntu
package so that applications can be compiled on Noble? Thanks.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/boost-defaults/+bug/2122352/+subscriptions
References