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

           Summary: string mixn results in dmd running out of memory
           Product: D
           Version: unspecified
          Platform: Other
        OS/Version: Linux
            Status: NEW
          Severity: critical
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: jmdavisp...@gmx.com


--- Comment #0 from Jonathan M Davis <jmdavisp...@gmx.com> 2010-10-03 02:25:19 
PDT ---
This lovely little program:

import std.algorithm;
import std.range;

immutable string[] tokens = [null, ";", "{", "}", "\"", "\\", "//", "/+", "+/",
"/*", "*/", "unittest", "import"];

string findTokensStr(string varName, string rangeName)
{
    string findClause = "auto " ~ varName ~ " = find(" ~ rangeName;

    foreach(string token; tokens[1..$])
    {
        if(token.startsWith("\"") || token.startsWith("\\"))
            findClause ~= ", \"\\" ~ token ~ "\"";
        else
            findClause ~= ", \"" ~ token ~ "\"";
    }

    return findClause ~ ");";
}

void main()
{
    string str = "my string";

    mixin(findTokensStr("found", "str"));
}


causes dmd to exit with

Error: out of memory


This may or may not be due to bug # 1382, but it certainly means that this
fairly simple string-constructing function can't be used with CTFE. Hopefully
it can be done with an eponymous template, but depending on the exact cause,
that may not work either. Regardless, this is a serious bug. It runs just fine
if yo just print the string instead of mixing it in, but as soon as you mix it
in, both the CPU and memory consumption blossom until dmd runs out of memory.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to