[Issue 5606] New: [CTFE] filter(iota) minus enforce

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 17 14:50:42 PST 2011


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

           Summary: [CTFE] filter(iota) minus enforce
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody at puremagic.com
        ReportedBy: bearophile_hugs at eml.cc


--- Comment #0 from bearophile_hugs at eml.cc 2011-02-17 14:48:06 PST ---
In attach there is a CTFE bug I don't understand, dmd 2.052beta. I have reduced
it from Phobos filter() and iota() code, but it's about one hundred lines
still.

This main doesn't compile:

void main() {
    auto odds = filter!isOdd(iota(0, 10, 1));
    auto b1 = foo!isOdd(iota(0, 10, 1)); // OK
    enum b2 = foo!isOdd(iota(0, 10, 1)); // Error
}


This compiles:

void main() {
    auto b1 = foo!isOdd(iota(0, 10, 1));
    enum b2 = foo!isOdd(iota(0, 10, 1));
}


This too:

void main() {
    auto b1 = foo!isOdd(iota(0, 10, 1));
    enum b2 = foo!isOdd(iota(0, 10, 1));
    auto odds = filter!isOdd(iota(0, 10, 1));
}


This too:

void main() {
    auto odds = filter!isOdd(iota(0, 10, 1));
    auto b1 = foo!isOdd(iota(0, 10, 1));
}


In a bit more longer version of the code, removing this produced a stack
overflow (not anymore), so the cause may be isInfinite or isInputRange:

static if (isInfinite!Range) {


(Beside killing inlining, reducing performance, and not allowing the nothrow
tag, the enforce() also makes a function not fit for CTFE. Here I have
commented out the enforce()).

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


More information about the Digitalmars-d-bugs mailing list