http://d.puremagic.com/issues/show_bug.cgi?id=8758

           Summary: A problem with zip.map.reduce at compile time
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nob...@puremagic.com
        ReportedBy: bearophile_h...@eml.cc


--- Comment #0 from bearophile_h...@eml.cc 2012-10-04 09:50:38 PDT ---
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/llfilfmmkvobsijdv...@forum.dlang.org

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to