D - bug in debug inside a contract
- Daniel Yokomiso (65/65) Apr 21 2003 Hi,
Hi, The following snippet makes the dmd 0.61 crash in semantic3 phase: module bug; public template TRange(T) { debug private bit recursing = false; public class Range { private T _lower; private T _upper; public this(T lower, T upper) { this._lower = lower; this._upper = upper; } public T lower() { return this._lower; } public T upper() { return this._upper; } public bit contains(T item) { return (lower() <= item) && (item <= upper()); } public bit intersects(Range other) in { assert(other !== null); } out (result) { debug { if (!recursing) { recursing = true; assert(result == other.intersects(this)); } else { recursing = false; } } } body { return contains(other.lower()) || contains(other.upper()) || other.includes(this); } public bit includes(Range other) in { assert(other !== null); } out (result) { assert(result == (contains(other.lower()) && contains(other.upper()))); } body { return contains(other.lower()) && contains(other.upper()); } } } int main() { alias instance TRange(int).Range Range; Range r1 = new Range(1, 10); Range r2 = new Range(5, 15); printf("%d\r\n", r1.intersects(r2)); return 0; } If we compile it using -debug nothing wrong happens. In dmd 0.59 this problem didn't happen. Best regards, Daniel Yokomiso. "As if you could kill time without injuring eternity." - Henry David Thoreau --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.474 / Virus Database: 272 - Release Date: 18/4/2003
Apr 21 2003