Merge pull request #1060 from EXetoC/vm-arithmetic-overflow

Arithmetic underflow/overflow checking for the VM
This commit is contained in:
Andreas Rumpf
2014-04-02 19:59:26 +02:00
6 changed files with 105 additions and 6 deletions

View File

@@ -0,0 +1,11 @@
discard """
errormsg: "over- or underflow"
"""
static:
proc p =
var
x = int64.high
discard x + 1
assert false
p()

View File

@@ -0,0 +1,12 @@
discard """
errormsg: "over- or underflow"
"""
static:
proc p =
var
x = int64.high
y = 1
discard x + y
assert false
p()

View File

@@ -0,0 +1,11 @@
discard """
errormsg: "over- or underflow"
"""
static:
proc p =
var
x = 1 shl 62
discard x * 2
assert false
p()

View File

@@ -0,0 +1,10 @@
discard """
errormsg: "over- or underflow"
"""
static:
proc p =
var x = int64.low
discard x - 1
assert false
p()

View File

@@ -0,0 +1,12 @@
discard """
errormsg: "over- or underflow"
"""
static:
proc p =
var
x = int64.low
y = 1
discard x - y
assert false
p()