[Issue 1790] New: CTFE: foreach(Tuple) won't compile if Tuple contains string

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Jan 17 11:56:44 PST 2008


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

           Summary: CTFE: foreach(Tuple) won't compile if Tuple contains
                    string
           Product: D
           Version: 1.025
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


Oddly, it compiles if you commment out the ; -- the foreach has to be
non-empty. Behaviour is quite odd; if there are several items in the tuple, it
will work if you don't use the whole tuple; eg Types[0..$-1] and Types[1..$]
will work. So it sounds like some kind of memory corruption/unterminated string
or similar.

Possibly the root cause of some of the bugs in issue 1298.

========
bug.d(9): Error: cannot evaluate foo() at compile time
---
int foo(Types...)() {
    foreach(T; Types) {
        ;   // will compile if you remove this line
    }
    return 0;
}

const int q = foo!("")();


-- 



More information about the Digitalmars-d-bugs mailing list