Weird behaviour when using -release in dmd

Jonathan M Davis via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 6 05:23:06 PDT 2014


On Fri, 06 Jun 2014 10:10:24 +0000
Mikko Aarnos via Digitalmars-d-learn
<digitalmars-d-learn at puremagic.com> wrote:

> Hello all, I have a program which works perfectly when compiled
> without -release:
>
> parser "a implies b equivalent not b implies not a"
> Input: ((a implies b) equivalent ((not b) implies (not a)))
> CNF: (((((not a) or b) or (not b)) and (((not a) or b) or a)) and
> (((b or (not a
> )) or a) and ((b or (not a)) or (not b))))
> Time(in ms) = 0
>
> However, when I add -release, this happens:
>
> parser "a implies b equivalent not b implies not a"
> object.Error: assert(0) or HLT instruction
> ----------------
> 0x0040220C
> 0x0040208F
> 0x0040206B
> 0x00403AAF
> 0x004084C8
> 0x0040849B
> 0x004083B4
> 0x0040454B
> 0x74F0338A in BaseThreadInitThunk
> 0x774A9F72 in RtlInitializeExceptionChain
> 0x774A9F45 in RtlInitializeExceptionChain
>
> Does anybody here have any idea what could cause this? The error
> seems to happen in a completely innocent part of code without any
> reason so I haven't the faintest idea what could cause it. I can
> post the source code if necessary, it's not long (under 1000
> lines including unit tests) but it's probably pretty hard to read
> on some parts, mainly the parser.

I don't think that we can help you much without more code. If you hit an
assert(0), then it's usually because of one of two reasons.

1. You have an assert(0) in your code (or an assertion where the condition is
statically known to be equivalent to 0).

2. You hit the end of a function without hitting a proper return statement.

There are probably a few others, but those are the two main ones that come to
mind at the moment. Now, normally, I'd expect to see an AssertError throw
without -release rather than your program working fine, so that makes me
wonder whether you have any variables which aren't being initialized properly
- though usually, that can only happen if you initialiaze a variable to void,
so I wouldn't have thought that that would the problem, since most people
don't do that. And of course it's always possible that you found a compile
bug, but without code that we can compile ourselves, I don't think that we can
help much.

You could use https://github.com/CyberShadow/DustMite to reduce the code to
something much smaller which still exhibits the problem (and is what you
really should do if you need to report a compiler bug anyway, which you might
in this case).

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list