www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5937] New: Problem with map!delegate(iota(floating point))

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5937

           Summary: Problem with map!delegate(iota(floating point))
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



With DMD 2.052 this gives some access violations:


import std.range, std.algorithm;
void main() {
    auto range1 = iota(0.0, 5.0, 1.0);
    double foo(double x){ return 1.0; };
    auto foor = map!foo(range1);
    foreach (x; foor) {} // OK

    auto range2 = iota(1, 5, 1);
    int bar(int x){ return 1; };
    auto barr = map!bar(range2);
    foreach (x; barr) {} // OK

    float delegate(float) spam1 = (float x){ return 1.0f; };
    auto spamr1 = map!spam1(range1);
    foreach (x; spamr1) {} // object.Error: Access Violation

    double delegate(double) spam2 = (double x){ return 1.0; };
    auto spamr2 = map!spam1(range1);
    foreach (x; spamr2) {} // object.Error: Access Violation

    real delegate(real) spam3 = (real x){ return 1.0L; };
    auto spamr3 = map!spam3(range1);
    foreach (x; spamr3) {} // object.Error: Access Violation
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5937




A better example for the second (bar) case, the problem seems in iota():


import std.range, std.algorithm;
void main() {
    auto range2a = iota(1, 5, 1);
    int delegate(int) bar1 = (int x){ return 1; };
    auto barr1 = map!bar1(range2a);
    foreach (x; barr1) {} // OK

    auto range2b = iota(1, 5, 1);
    double delegate(double) bar2 = (double x){ return 1.0; };
    auto barr2 = map!bar2(range2b);
    foreach (x; barr2) {} // OK
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 06 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5937


Ali Cehreli <acehreli yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |acehreli yahoo.com



This doesn't seem to be an issue anymore. Both of the programs compile and run
successfully. (After removing two extraneous semicolons.)

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 04 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=5937


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WORKSFORME


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