import strutils
proc GetInt(): int = stdin.readLine.parseInt
var
Chunk = GetInt()
ChunkSize = 1024
Offset = Chunk * ChunkSize
if Chunk < 0 or Offset < 0:
quit 0
echo Offset
quit 1
Run with
$ nim -d:release c minbug.nim && echo 1000000000000000000 | ./minbug
-9017668127734890496
Depending on the underlying C compiler and optimization level Offset can be printed in the end, even when it's negative, because of signed integer overflows. The behaviour of a program with signed integer overflow is undefined in C, so gcc 4.8 with -O2 optimizes the Offset < 0 away, while gcc 4.7 does not.
This behaviour has long been known, see for example: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=30475 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49820 https://gcc.gnu.org/ml/gcc-help/2011-07/msg00219.html
I don't know whether this behaviour is wanted in Nim.