www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18211] New: Access violation when generating JSON on static

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

          Issue ID: 18211
           Summary: Access violation when generating JSON on static
                    foreach
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: Bastiaan Veelo.net

Code containing this valid mixin template
```
mixin template withEnum(E) if (is(E == enum))
{
    import std.traits;
    import std.format;
    static foreach (i, member; EnumMembers!E)
        mixin(format!"alias %s = %s.%s;\n"(member, __traits(identifier, E),
member));
}
```
causes dmd to halt with an access violation when the -X option is given:

dmd -o- -X bug.d

object.Error (0): Access Violation
----------------
0x00413D42
0x00409997
0x00519116
0x00519EF3
0x0058BF4D
0x771E1BC5 in RtlQueryProcessDebugInformation
0x771E15A2 in RtlCreateQueryDebugBuffer
0x7715D5ED in RtlDllShutdownInProgress
0x77174104 in RtlAllocateHeap
0x7717334D in RtlAllocateHeap
0x69000B62


Otherwise the code compiles and works as intended:
unittest
{
    enum Enumer {One, Four = 4, Five, Six, Ten = 10}
    mixin withEnum!(Enumer);
    static assert(One == Enumer.One);
    static assert(Four == Enumer.Four);
}

This is a problem for ddox: it won't generate documentation for my project
because of this.

--
Jan 08 2018