diff --git a/AUTHORS.txt b/AUTHORS.txt index 8089802f5..5b2cdd084 100644 --- a/AUTHORS.txt +++ b/AUTHORS.txt @@ -44,6 +44,8 @@ Dr Ian Bush [consultant] HPC External contributors: +James Richings + patched overflow in bitwise.hpp logic Luc Jaulmes patched v4's install process using CMake Jakub Adamski diff --git a/README.md b/README.md index bab2d2ff6..260d4b8bb 100644 --- a/README.md +++ b/README.md @@ -257,6 +257,7 @@ See the [docs](docs/README.md) for enabling acceleration and running the unit te In addition to QuEST's [authors](AUTHORS.txt), we sincerely thank the following external contributors to QuEST. +- [James Richings](https://github.com/JPRichings) for patching a v4 overflow bug. - [Luc Jaulmes](https://github.com/lucjaulmes) for patching v4's CMake installation. - [Jakub Adamski](https://github.com/jjacobx) for optimising distributed communication of max-size messages. - [Bruno Villasenor Alvarez](https://github.com/bvillasen) of [AMD](https://www.amd.com/en.html) for porting the v3 GPU backend to [HIP](https://github.com/ROCm-Developer-Tools/HIP), for compatibility with AMD GPUs. diff --git a/quest/src/core/bitwise.hpp b/quest/src/core/bitwise.hpp index 910840478..5479c4ee0 100644 --- a/quest/src/core/bitwise.hpp +++ b/quest/src/core/bitwise.hpp @@ -4,6 +4,7 @@ * * @author Tyson Jones * @author Erich Essmann (improved OS agnosticism) + * @author James Richings (patched setBit) */ #ifndef BITWISE_HPP @@ -106,7 +107,8 @@ INLINE qindex insertBit(qindex number, int bitIndex, int bitValue) { INLINE qindex setBit(qindex number, int bitIndex, int bitValue) { - qindex bitInPlace = bitValue << bitIndex; + // beware that shifting the raw int would overflow (#623) + qindex bitInPlace = ((qindex) bitValue) << bitIndex; qindex oneInPlace = QINDEX_ONE << bitIndex; return (number & ~oneInPlace) | bitInPlace; }