[Issue 21008] New: dmd segfaults because of __traits(getMember, ...) and virtual function overriding

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jul 3 10:35:24 UTC 2020


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

          Issue ID: 21008
           Summary: dmd segfaults because of __traits(getMember, ...) and
                    virtual function overriding
           Product: D
           Version: D2
          Hardware: x86
                OS: All
            Status: NEW
          Severity: critical
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: bitworld at qq.com

When compiling the test code with dmd, the compiler will crash.

Test with dmd 2.092.0 and 2.088.1 on Windows and Linux.


Here is the code:
======================================
void main() {}

import std.traits;

abstract class Controller {
    bool after();
}

abstract class ControllerBase(T) : Controller {
    override bool after() {
        return true;
    }

    mixin(handleMiddlewareAnnotation!(T));
}

class DemoController : ControllerBase!DemoController {

    // Bug mark A
    override bool after() {
        return true;
    }
}

string handleMiddlewareAnnotation(T)() {

    foreach (memberName; __traits(allMembers, T)) {
        alias currentMember = __traits(getMember, T, memberName); // Bug mark B
    }

    return "";
}
======================================

After commenting out the mark A or the mark B, the compiling will pass.

--


More information about the Digitalmars-d-bugs mailing list