mirror of
https://github.com/gbdev/rgbds.git
synced 2026-10-06 12:15:39 +00:00
Correct assumption to avoid UB with 1 << 31
This commit is contained in:
1 parent
39e7e064c9
commit
b8011947a8
2 files changed
+2
-2
No files matched your search
+1
-1
@@ -486,7 +486,7 @@ void Expression::checkNBit(uint8_t n) const {
|
||||
|
||||
bool checkNBit(int32_t v, uint8_t n, char const *name) {
|
||||
assume(n != 0); // That doesn't make sense
|
||||
assume(n < CHAR_BIT * sizeof(int)); // Otherwise `1 << n` is UB
|
||||
assume(n < CHAR_BIT * sizeof(int) - 1); // Otherwise `1 << n` is UB
|
||||
|
||||
if (v < -(1 << n) || v >= 1 << n) {
|
||||
warning(
|
||||
|
||||
+1
-1
@@ -522,7 +522,7 @@ void patch_CheckAssertions() {
|
||||
|
||||
static void checkPatchSize(Patch const &patch, int32_t v, uint8_t n) {
|
||||
assume(n != 0); // That doesn't make sense
|
||||
assume(n < CHAR_BIT * sizeof(int)); // Otherwise `1 << n` is UB
|
||||
assume(n < CHAR_BIT * sizeof(int) - 1); // Otherwise `1 << n` is UB
|
||||
|
||||
if (v < -(1 << n) || v >= 1 << n) {
|
||||
diagnosticAt(
|
||||
|
||||
Reference in new issue
Block a user