fixes #12310 [backport] (#12470)

(cherry picked from commit 38b3590e40)
This commit is contained in:
Andreas Rumpf
2019-10-20 22:37:31 +02:00
committed by narimiran
parent 1526ae8791
commit 0b134412f8
2 changed files with 20 additions and 2 deletions

View File

@@ -948,9 +948,13 @@ proc genMagic(c: PCtx; n: PNode; dest: var TDest; m: TMagic) =
c.genAddSubInt(n, dest, opcAddInt)
of mInc, mDec:
unused(c, n, dest)
let opc = if m == mInc: opcAddInt else: opcSubInt
let isUnsigned = n.sons[1].typ.skipTypes(abstractVarRange).kind in {tyUInt..tyUInt64}
let opc = if not isUnsigned:
if m == mInc: opcAddInt else: opcSubInt
else:
if m == mInc: opcAddu else: opcSubu
let d = c.genx(n.sons[1])
if n.sons[2].isInt8Lit:
if n.sons[2].isInt8Lit and not isUnsigned:
c.gABI(n, succ(opc), d, d, n.sons[2].intVal)
else:
let tmp = c.genx(n.sons[2])

View File

@@ -200,3 +200,17 @@ const
vmCrash = oh_no()
debugEcho vmCrash
# bug #12310
proc someTransform(s: var array[8, uint64]) =
var s1 = 5982491417506315008'u64
s[1] += s1
static:
var state: array[8, uint64]
state[1] = 7105036623409894663'u64
someTransform(state)
doAssert state[1] == 13087528040916209671'u64