Skip to content

Fix UB in benchmark #96

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

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

Conversation

hebasto
Copy link
Member

@hebasto hebasto commented Jun 2, 2025

From https://en.cppreference.com/w/c/language/operator_arithmetic.html:

The behavior is undefined if rhs is negative or is greater or equal the number of bits in the promoted lhs.

Steps to reproduce on Ubuntu 25.04 using the master branch @ ea8f66b:

$ ./autogen.sh
$ ./configure --enable-benchmark CXX=clang++-20 CXXFLAGS="-O0"
$ make bench -j $(nproc) bench
$ ./bench
<snip>
recover[ms]	 63	 260.72278	         -	  62.21269	
create[ns]	 63	  79.66483	         -	  17.74962	
/usr/lib/gcc/x86_64-linux-gnu/15/../../../../include/c++/15/bits/uniform_int_dist.h:108: std::uniform_int_distribution<unsigned long>::param_type::param_type(_IntType, _IntType) [_IntType = unsigned long]: Assertion '_M_a <= _M_b' failed.
Aborted (core dumped)

From https://en.cppreference.com/w/c/language/operator_arithmetic.html:
> The behavior is undefined if rhs is negative or is greater or equal
> the number of bits in the promoted lhs.
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.

1 participant