mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-23 19:42:08 +00:00
Fix UBSan error with overflowing exponent operator (#1727)
This commit is contained in:
11
test/asm/exponent.asm
Normal file
11
test/asm/exponent.asm
Normal file
@@ -0,0 +1,11 @@
|
||||
def n = 30
|
||||
for x, -n, n
|
||||
for p, n
|
||||
def v1 = x ** p
|
||||
def v2 = 1
|
||||
for i, p
|
||||
def v2 *= x
|
||||
endr
|
||||
assert v1 == v2, "{d:x}**{d:p} = {d:v1} or {d:v2}?"
|
||||
endr
|
||||
endr
|
||||
@@ -34,6 +34,12 @@ def x = x << 1
|
||||
dl -1 << 1
|
||||
print_x
|
||||
|
||||
def x = 2 ** 31
|
||||
print_x
|
||||
|
||||
def x = 5 ** 29
|
||||
print_x
|
||||
|
||||
def x = 4294967295
|
||||
def x = 4294967296
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ warning: overflow.asm(23): [-Wdiv]
|
||||
Division of -2147483648 by -1 yields -2147483648
|
||||
warning: overflow.asm(24): [-Wdiv]
|
||||
Division of -2147483648 by -1 yields -2147483648
|
||||
warning: overflow.asm(38): [-Wlarge-constant]
|
||||
warning: overflow.asm(44): [-Wlarge-constant]
|
||||
Integer constant is too large
|
||||
warning: overflow.asm(41): [-Wlarge-constant]
|
||||
warning: overflow.asm(47): [-Wlarge-constant]
|
||||
Graphics constant is too long, only first 8 pixels considered
|
||||
|
||||
@@ -4,3 +4,5 @@ $80000000
|
||||
$80000000
|
||||
$0
|
||||
$FFFFFFFE
|
||||
$80000000
|
||||
$6B90BE55
|
||||
|
||||
Reference in New Issue
Block a user