[Issue 4984] string mixn results in dmd running out of memory

2011-04-11 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4984


kenn...@gmail.com changed:

   What|Removed |Added

 CC||kenn...@gmail.com
Version|unspecified |D2
 OS/Version|Linux   |All


--- Comment #2 from kenn...@gmail.com 2011-04-11 14:46:35 PDT ---
This is likely due to the recursive template constraint used in
std.algorithm.startsWith. A reduced test case:

---

void x(U...)(U args) if ( is(typeof( x(args[1..$]) )) ) {
}

void x(U)(U u) {
}

void main() {
x(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20);
}

---

Similar test case:

---

void x(int n)() if (n > 0 && is(typeof(x!(n-1) ( {
}

void x(int n : 0)() {
}

void main() {
x!20();
}

---

Phobos could workaround this by moving the recursive part into a
static-if/static-assert.

(Note: I only check if it consumes an unusually large amount memory and does
not stop. I didn't wait until it runs out of memory.)

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


[Issue 4984] string mixn results in dmd running out of memory

2010-10-03 Thread d-bugmail
http://d.puremagic.com/issues/show_bug.cgi?id=4984



--- Comment #1 from Jonathan M Davis  2010-10-03 03:52:31 
PDT ---
This is worse than I thought. The problem has nothing to do with the mixin at
all. Maybe constructing the string for the mixin helps make dmd run out of
memory, maybe not, but the find() is enough to do it. Take this program for
instance

import std.algorithm;

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

auto found = find(str, ";", "{", "}", "\\\"", "\"", "//", "/+", "+/", "/*",
"*/", "unittest", "import");
}

It runs out of memory just fine on its own, without the mixin. find() is going
to be rather limiting if it can't be used with more than a few possible
needles. Granted, the most typical use case is a single needle, but dmd really
should be able to handle a more or less arbitrary number of needles (though
obviously something like 100 needles wouldn't necessarily be reasonable). In
any case, 12 needles is enough. If I remove one and make it 11, then a
ridiculous amount of memory is used, but at least dmd doesn't run out. With 12,
it does.

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