Bug 5606 – [CTFE] filter(iota) minus enforce

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-02-17T14:48:00Z
Last change time
2011-06-07T01:23:06Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Attachments

IDFilenameSummaryContent-TypeSize
914test4.dfilter(iota) minus enforce, reduced in many waysapplication/octet-stream2327

Comments

Comment #0 by bearophile_hugs — 2011-02-17T14:48:06Z
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()).
Comment #1 by bearophile_hugs — 2011-02-17T14:49:08Z
Created attachment 914 filter(iota) minus enforce, reduced in many ways
Comment #2 by clugdbug — 2011-06-07T01:23:06Z
Reduced test case: ------------- struct Bug5606 { bool empty(){ return true; } } static assert(!is(char[1 + Bug5606.empty])); static assert(Bug5606().empty()); It's a dup of bug 4910 which is fixed in git. *** This issue has been marked as a duplicate of issue 4910 ***