mirror of
https://github.com/gbdev/rgbds.git
synced 2026-08-24 07:44:32 +00:00
Fix C++ UB from negating INT_MIN with macro shift INT_MIN
This commit is contained in:
+1
-1
@@ -72,7 +72,7 @@ void MacroArgs::shiftArgs(int32_t count) {
|
||||
count > 0 && (static_cast<uint32_t>(count) > nbArgs || shift > nbArgs - count)) {
|
||||
warning(WARNING_MACRO_SHIFT, "Cannot shift macro arguments past their end");
|
||||
shift = nbArgs;
|
||||
} else if (count < 0 && shift < static_cast<uint32_t>(-count)) {
|
||||
} else if (count < 0 && (count == INT32_MIN || shift < static_cast<uint32_t>(-count))) {
|
||||
warning(WARNING_MACRO_SHIFT, "Cannot shift macro arguments past their beginning");
|
||||
shift = 0;
|
||||
} else {
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
MACRO m
|
||||
println \1
|
||||
shift $8000_0000 ; INT32_MIN
|
||||
println \1
|
||||
ENDM
|
||||
m 1, 2, 3
|
||||
@@ -0,0 +1,2 @@
|
||||
warning: Cannot shift macro arguments past their beginning [-Wmacro-shift]
|
||||
at shift-int-min.asm::m(3) <- shift-int-min.asm(6)
|
||||
@@ -0,0 +1,2 @@
|
||||
$1
|
||||
$1
|
||||
Reference in New Issue
Block a user