Bug 8758 – A problem with zip.map.reduce at compile time

Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-10-04T09:50:00Z
Last change time
2014-05-11T18:32:11Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2012-10-04T09:50:38Z
I am not sure if this is a bug or just a problem in my code: import std.algorithm: map, reduce; import std.range: zip; struct S {} alias bool function(S) F; F foo(T)(T) { return p => true; } F bar(F r1, F r2) { return p => true; } F spam(S[] ps) { return zip(ps, ps).map!foo().reduce!bar(); } const r1 = spam([S(), S()]); // Error void main() { const r2 = spam([S(), S()]); // OK } Output, DMD 2.061alpha: ...\dmd2\src\phobos\std\conv.d(3393): Error: cannot dereference invalid pointer *result ...\dmd2\src\phobos\std\range.d(3714): called from here: emplace(addr,front(this.ranges._field_field_0)) ...\dmd2\src\phobos\std\algorithm.d(428): called from here: this._input.front() ...\dmd2\src\phobos\std\algorithm.d(428): called from here: foo(this._input.front()) ...\dmd2\src\phobos\std\algorithm.d(697): called from here: _param_0.front() temp.d(12): called from here: reduce(map(zip(ps,ps))) temp.d(14): called from here: spam([S(),S()]) I have asked about it here: http://forum.dlang.org/thread/[email protected]
Comment #1 by monarchdodra — 2014-03-18T07:23:40Z
I have an improvement for Zip in the pipes that seems to fix this.
Comment #2 by monarchdodra — 2014-05-10T11:01:53Z
I don't know what happened, but this seems to work now. @bearophile: Confirm resolved worksforme?
Comment #3 by bearophile_hugs — 2014-05-11T18:32:11Z
Now it works, issue closed.