https://issues.dlang.org/show_bug.cgi?id=15573
--- Comment #22 from [email protected] --- Basically, dustmite does textual simplification, which often, though not always, corresponds with semantic simplification. For example, it does replace selective imports with non-selective imports -- it's a textual simplification but not necessarily a semantic one. It doesn't actually look into the imported code unless the imported module is also part of the source tree being reduced. Anyway, dustmite didn't get me very far in reducing the code any further; here's how far it got: ------ import std.stdio; enum IntFlag {NULL, error} IntFlag intFlag; int dummyVar; int safeDiv(byte left, byte right) { const div0 = right == 0; const posOver = left == int.min&& right ; if(div0) { intFlag = posOver ? IntFlag.error : IntFlag.error; return 0; } return left / right; } void main() { byte[] testValues = [-2]; foreach(m; testValues) foreach(n; testValues) { const theory = cast(real)n / m; const thrInval = theory.isNaN; intFlag = IntFlag.NULL; const practice1 = safeDiv(n, m); writeln(practice1 == theory); /* false with -inline -O */ void require(bool success) { if(success) dummyVar = m; } require(thrInval); } } bool isNaN(real x) { enum EXPMASK = 0x7FFF; enum EXPPOS_SHORT = 4; const e = EXPMASK & (cast(ushort *)&x)[EXPPOS_SHORT]; const ps = *cast(ulong *)&x; return e == EXPMASK && ps & 0x7FFF_FFFF_FFFF_FFFF; } ------ (I left std.stdio in there and replaced the assert with a writeln, because dustmite needed a script that can tell the difference between a correct reduction and an incorrect reduction -- I have to compile it with and without the offending flags and grep for "false" and "true", respectively, so that dustmite doesn't barge ahead and just replace the assert with something that vacuously fails. :-P) Looks like I will have to look into the generated asm next... --
