Bug 4746 – CTFE regression + CTFE/normal execution differences (splitlines).

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2010-08-28T14:06:00Z
Last change time
2010-12-08T07:09:08Z
Assigned to
nobody
Creator
peter.alexander.au

Comments

Comment #0 by peter.alexander.au — 2010-08-28T14:06:28Z
This is two bugs at once. The first is a regression in 2.048 from 2.047 where splitlines is no longer CTFEable. The second is that, in 2.047, splitlines doesn't work when CTFE'd. // 2.048 void main() { static auto s = splitlines("a\nb"); // Error: not CTFEable writeln(s[0]); } // 2.047 void main() { auto s = splitlines("a\nb"); // Note non-static writeln(s[0]); // Writes 'a'... correct! } // 2.047 void main() { static auto s = splitlines("a\nb"); // CTFE'd this time writeln(s[0]); // Writes nothing... incorrect! } Note that the 2.048 was run on Windows 7 and the 2.047 was run on Mac OS X Snow Leopard. Also note that string.split appears to have the same issue (was CTFEable in 2.047, but not in 2.048).
Comment #1 by clugdbug — 2010-12-08T07:09:08Z
Compiler versions before 2.048 silently generated wrong code for CTFE situations like this one. This bug was fixed in 2.048, and it now (correctly) says that it cannot compile it.