DbC bug?
H. S. Teoh
hsteoh at quickfur.ath.cx
Thu Feb 23 07:59:18 PST 2012
On Thu, Feb 23, 2012 at 11:42:35AM +0100, Magnus Lie Hetland wrote:
> I think I've stumbled across a DbC bug. In an out-block, I have the
> assertion `assert(id < objs.length);`. Now, if I don't have an
> in-block, this fails. However, if I add an in-block (with basically
> any code that isn't optimized away, or so it seems), the assertion
> succeeds. (Before this was an assertion, the failure was a range
> violation from objs[id]; the behavior is equivalent for that.)
[...]
> It seems that the id variable (a parameter of the method) is actually
> undefined in the out-block, and that this is the reason for the error.
> (The program is run with the same random seeds, but the id variable,
> which *should* be in 0..1000, ends up with varying values such as
> 1609528144, 1653547856 or 1816621904.
[...]
Looks like a compiler bug. You should never be able to access invalid
values.
T
--
"A man's wife has more power over him than the state has." -- Ralph Emerson
More information about the Digitalmars-d-learn
mailing list