[Issue 18026] Stack overflow in ddmd/dtemplate.d:6241, TemplateInstance::needsCodegen()

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 18 10:51:06 UTC 2018


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

FeepingCreature <default_357-line at yahoo.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |default_357-line at yahoo.de

--- Comment #15 from FeepingCreature <default_357-line at yahoo.de> ---
Shorter repro:

module test;

struct FormatSpec() {}

void formatValueImpl(W, T)(W w, T obj, FormatSpec!() f) if (is(T == string)) {
}

void formatValueImpl(W, T)(W w, T val, FormatSpec!() f)
if (is(T == int))
{
    import std.range : iota;
    static foreach (_; iota(1000))
    {
        formatValueImpl!(W, string)(w, "", f);
    }
}

void formatValueImpl(W, T)(W w, T obj, FormatSpec!() f) if (false) {}
void formatValueImpl(W, T)(W w, T obj, FormatSpec!() f) if (false) {}
void formatValueImpl(W, T)(W w, T obj, FormatSpec!() f) if (false) {}
void formatValueImpl(W, T)(W w, T obj, FormatSpec!() f) if (false) {}

alias fvi_Type_1 = formatValueImpl!(void function(char c), int);
alias fvi_Type_2 = formatValueImpl!(void function(const(char)[] s), int);
alias fvi_Type_3 = formatValueImpl!(void delegate(char c), int);
alias fvi_Type_4 = formatValueImpl!(void delegate(const char[]), int);
alias fvi_Type_5 = formatValueImpl!(void delegate(const(char)[] s), int);

void main() {}

Seems to happen more reliably in gdb. Since it's a stack overflow, recommended
to limit your stack size with ulimit -s 128 to test.

--


More information about the Digitalmars-d-bugs mailing list