[Issue 4984] New: string mixn results in dmd running out of memory
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun Oct 3 02:26:08 PDT 2010
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: nobody at puremagic.com
ReportedBy: jmdavisProg at gmx.com
--- Comment #0 from Jonathan M Davis <jmdavisProg at 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: -------
More information about the Digitalmars-d-bugs
mailing list