digitalmars.D.bugs - [Issue 22996] New: [ICE] Parsing at CTFE crash the compiler
- d-bugmail puremagic.com (64/64) Apr 07 2022 https://issues.dlang.org/show_bug.cgi?id=22996
https://issues.dlang.org/show_bug.cgi?id=22996 Issue ID: 22996 Summary: [ICE] Parsing at CTFE crash the compiler Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody puremagic.com Reporter: aliloko gmail.com Created attachment 1844 --> https://issues.dlang.org/attachment.cgi?id=1844&action=edit Main source file I lost an excellent potential contributor because he was not impressed with D, after encountering bugs and regressions. The following program he wanted to compile but exhausted memory. ------------------------------------------------------- import std.stdio; import std.string; import std.range; import std.array; import std.typecons; import std.complex; enum TEXT = import("shape-L8.txt"); enum Tuple!(double, Complex!double)[] DATA = mixin(TEXT.transformLTSpiceToCode); string transformLTSpiceToCode(string text) { string result; result.reserve(1_000_000); result ~= "["; foreach (string line; text.lineSplitter.dropOne) { string[] fields = line.split!`a == ' ' || a == '\t' || a == ','`.array; result ~= "std.typecons.Tuple!(double, std.complex.Complex!double)("; result ~= fields[0]; result ~= ",Complex!double("; result ~= fields[1]; result ~= ","; result ~= fields[2]; result ~= ")),\n"; } result ~= "]"; return result; } void main(string[] args) { writeln(DATA); } ------------------------------------------------------- To a seasoned D programmer, it is obvious why the program uses up all memory: it uses tuples, std.complex, lazy ranges, arrays liberally at CTFE. It is of course possible to make it work at CTFE with more pedestrian code. But a newfound D user will just dismiss the language without knowing he is perhaps amongst the only to use such a costly CTFE program. And then the compiler crashing is an ICE. 1. unzip the attached file and get shape-L8.txt 2. run the above program DMD will crash after exhausting memory. Better outcome with -lowmem, who caps memory usage at 100mb. --
Apr 07 2022