www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10922] New: Compiler segfaults when using __traits(parent, {})

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

           Summary: Compiler segfaults when using __traits(parent, {})
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: monkeyworks12 hotmail.com


--- Comment #0 from monkeyworks12 hotmail.com 2013-08-29 12:01:51 PDT ---
uint fib = (in uint n) pure nothrow {
    enum self = __traits(parent, {});
    return (n < 2) ? n : self(n - 1) + self(n - 2);
};

void main() 
{
    import std.stdio;

    writeln(fib(39));
}

This code causes a segfault, as does giving fib the auto storage class instead
of uint. If the code is changed to:

uint fib (in uint n) pure nothrow {
    immutable self = __traits(parent, {});
    return (n < 2) ? n : self(n - 1) + self(n - 2);
};

Then it does not segfault.

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