Closed lroberts36 closed 2 weeks ago
btw you got the Schnapszahl ;)
@pgrete: I am not sure why this worked previously, but I did not look carefully at what happened with the negative but shift. I think this should have been hit reasonably often.
Haha, I had to look up schnapszahl...
The test now reliably failed twice. Does anyone see how this changeset could result in that error? I don't.
The test now reliably failed twice. Does anyone see how this changeset could result in that error? I don't.
It's a NumPy 2.0 API breakage 😞...
AttributeError: module 'numpy' has no attribute 'product'
The test scripts need to be updated: https://numpy.org/devdocs/numpy_2_0_migration_guide.html#numpy-2-migration-guide
@pgrete and @BenWibking: Apparently this worked because (at least clang and gcc) bitshift negative numbers in the expected way, i.e neg_num << n == neg_num * std::pow(2, n)
.
@pgrete and @BenWibking: Apparently this worked because (at least clang and gcc) bitshift negative numbers in the expected way, i.e
neg_num << n == neg_num * std::pow(2, n)
.
great, thanks for confirming!
PR Summary
This PR fixes the bitshift related undefined behavior described in #1107 by multiplying by a power of two explicitly rather than performing the same operation (on positive numbers) via a bitshift.
PR Checklist