https://issues.dlang.org/show_bug.cgi?id=18804
ag0aep6g <ag0ae...@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull CC| |ag0ae...@gmail.com Component|dmd |phobos Hardware|x86 |All Summary|Side effects incorrectly |std.algorithm.mutation.copy |optimized out when results |puts whole source range |are discarded |into target range when it | |should put elements OS|Windows |All --- Comment #1 from ag0aep6g <ag0ae...@gmail.com> --- Generally, please post complete code, including imports. Also include the contents of other files like "in". What happens here is that `copy` puts the range as a whole into the NullSink. This is not DMD optimizing anything out. Reduced test case: ---- import std.algorithm.mutation: copy; struct NullSink { void put(E)(E) {} } int line = 0; struct R { int front; @property bool empty() { return line == 1; } void popFront() { line = 1; } } void main() { R r; copy(r, NullSink()); assert(line == 1); /* fails; should pass */ } ---- Pull request to fix this: https://github.com/dlang/phobos/pull/6485 --