diff --git a/rod/ccgexprs.nim b/rod/ccgexprs.nim index 6169c970c..da5e9b084 100755 --- a/rod/ccgexprs.nim +++ b/rod/ccgexprs.nim @@ -371,6 +371,25 @@ proc binaryArithOverflow(p: BProc, e: PNode, d: var TLoc, m: TMagic) = else: putIntoDest(p, d, e.typ, ropef("(NI$4)($2 $1 $3)", [toRope(opr[m]), rdLoc(a), rdLoc(b), toRope(getSize(t) * 8)])) + when false: + if optOverflowCheck in p.options: + # It would be better to just implement these + if getSize(t) < 4: + var tmp = getTempName() + appcg(p, cpsLocals, "NI32 $1;", [tmp]) + appcg(p, cpsStmts, "$1 = #$2($3, $4);", [tmp, toRope(prc[m]), rdLoc(a), rdLoc(b)]) + appcg(p, cpsStmts, "if ($1 < $2 || $1 > $3) #raiseOverflow();$n", + [tmp, intLiteral(firstOrd(t)), intLiteral(lastOrd(t))]) + putIntoDest(p, d, e.typ, tmp) + else: + putIntoDest(p, d, e.typ, ropecg(p.module, + "#$1($2, $3)", [toRope(prc[m]), rdLoc(a), rdLoc(b)])) + appcg(p, cpsStmts, "if ($1 < $2 || $1 > $3) #raiseOverflow();$n", + [rdLoc(d), intLiteral(firstOrd(t)), intLiteral(lastOrd(t))]) + else: + putIntoDest(p, d, e.typ, ropef("(NI$4)($2 $1 $3)", [toRope(opr[m]), + rdLoc(a), rdLoc(b), toRope(getSize(t) * 8)])) + proc unaryArithOverflow(p: BProc, e: PNode, d: var TLoc, m: TMagic) = const diff --git a/todo.txt b/todo.txt index 22529feb6..14f1c1f02 100755 --- a/todo.txt +++ b/todo.txt @@ -2,12 +2,13 @@ For version 0.8.10 ================== - fix implicit generic routines -- fix the streams implementation so that it uses methods +- bugfix: ccgexprs High priority (version 0.9.0) ============================= +- fix the streams implementation so that it uses methods - fix overloading resolution - wrong co-/contravariance diff --git a/tools/buildsh.tmpl b/tools/buildsh.tmpl index cdfdbf2c1..da034a76b 100755 --- a/tools/buildsh.tmpl +++ b/tools/buildsh.tmpl @@ -33,7 +33,7 @@ case $uos in *darwin* ) myos="macosx" LINK_FLAGS="$LINK_FLAGS -ldl -lm" - if [ `sysctl hw |grep 64bit` = "hw.cpu64bit_capable: 1" ] ; then + if [ "`sysctl hw |grep 64bit`" = "hw.cpu64bit_capable: 1" ] ; then ucpu="amd64" fi ;;