Bug 1790 – CTFE: foreach(Tuple) won't compile if Tuple contains string

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2008-01-17T13:56:00Z
Last change time
2014-02-24T15:33:21Z
Keywords
rejects-valid
Assigned to
nobody
Creator
clugdbug

Comments

Comment #0 by clugdbug — 2008-01-17T13:56:43Z
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!("")();
Comment #1 by clugdbug — 2009-02-03T08:18:08Z
This workaround for this bug has changed. On 1.039, it now fails even if you comment out the marked line. But it compiles if you add [] to the string. int foo(Types...)() { foreach(T; Types) { ; } return 0; } const int q = foo!("abc"[])(); // OK
Comment #2 by bugzilla — 2010-01-30T22:40:04Z
fixed dmd 1.056 and 2.040