[Issue 21473] DMD enters infinite loop

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Dec 11 22:57:59 UTC 2020


https://issues.dlang.org/show_bug.cgi?id=21473

Boris Carvajal <boris2.9 at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |boris2.9 at gmail.com

--- Comment #1 from Boris Carvajal <boris2.9 at gmail.com> ---
There are two issues here, the first is in phobos that somewhere in the
pipeline generates a ridiculous amount of template instances.

Second is the recursive nature of 'TemplateInstance::needsCodegen()' that
overflows the stack when there are too many instances of a particular template,
this is the same bug as issue 18026 and the only way to fix it is to refactor
'needsCodegen' function. You can reproduce it with this simple piece of code:

---------------
struct S() {}

static foreach (i; 0..180000)
{
    mixin("S!() s", i, ";");
}
---------------

The number of iterations can vary, for example using a non-optimized DMD build
I only need '90000' to crash. (my stack size is 8MB)

--


More information about the Digitalmars-d-bugs mailing list