I'm a noob in the Nim community, so apologies if I'm posting in the wrong forum.

I discovered a snippet of code which behaves differently depending on whether 
or not release mode is used for compilation. I'm wondering if this is a 
compiler bug or if I'm doing something wrong.

Here is source, **bug.nim**: 
    
    
    proc bug() : void =
        var x = 0
        try:
            inc x
            raise new(Exception)
        except Exception:
            echo x
    
    bug()
    

Here's what happens: 
    
    
    $ nim c bug.nim
    ...
    $ ./bug
    1
    $ nim c -d:release bug.nim
    ...
    $ ./bug
    0
    $ nim --version
    Nim Compiler Version 0.16.0 (2017-01-08) [MacOSX: amd64]
    Copyright (c) 2006-2017 by Andreas Rumpf
    
    git hash: 5947403e84ba44397b35f93f9d327c76e794210f
    active boot switches: -d:release
    

Please observe that the code prints **1** when using normal compilation and 
**0** when using release mode. Is this expected? Am I doing something wrong? 
Thanks for your help!

Reply via email to