dfmt at commit 48bc7ba0c2c115d3ba3175b591da4b46db57cb95 exhibits a code generation bug.
dfmt is located at https://github.com/Hackerpilot/dfmt
To reproduce, check out that specific commit and run "make test" with the line containing "version = WTF_DMD;" commented out. The code also seems to be sensitive to whether or not the "-O" flag is enabled.
I've inspected the ASM dumps of the program and haven't been able to figure out exactly where things are going wrong. I'll work on reducing this to a smaller test case.
Comment #1 by dlang-bugzilla — 2015-03-30T19:49:18Z
What DMD version?
With 2.066.0 I get:
src/dfmt/wrapping.d(187): Error: pure function 'dfmt.wrapping.validMoves!(RedBlackTree!(State, "a < b", false)).validMoves' cannot call impure function 'std.container.rbtree.RedBlackTree!(State, "a < b", false).RedBlackTree.stableInsert!(State).stableInsert'
src/dfmt/wrapping.d(165): Error: template instance dfmt.wrapping.validMoves!(RedBlackTree!(State, "a < b", false)) error instantiating
And then it seems to freeze up.
Comment #2 by briancschott — 2015-03-30T20:43:48Z
Reduced to a single file:
https://gist.github.com/Hackerpilot/9708cfa7ce0e259f1600
Compiler + flags | Output
------------------------+-------
ldc -d-version=WTF_DMD | 2400
ldc | 2400
dmd -version=WTF_DMD | 2400
dmd | 3080
dmd -version=WTF_DMD -O | 2400
dmd -O | 2400
Setting the version flag OR enabling optimizations causes good code generaton.
Comment #3 by briancschott — 2015-03-31T00:31:00Z
The code was calling bsf with an argument of 0, which is undefined. It behaved consistently, and the version and optimization flags could change its return value.
The real issue is that bsf is marked as a pure function when it isn't: https://issues.dlang.org/show_bug.cgi?id=14380