www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 20333] New: cannot get frame pointer to <template function>

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

          Issue ID: 20333
           Summary: cannot get frame pointer to <template function> when
                    passing base class element
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: puneet coverify.org

Compiles with LDC 1.18 release, but segfaults.
Fails to compile with DMD github HEAD.


import std.stdio: writeln;

class Frop { }

class Foo {
  Frop frop1;
}

class Bar: Foo {
  Frop frop0;
  void boo(alias V, string VS)() {
    writeln("boo: ", __traits(getMember, this, VS).stringof);
    writeln("boo: ", V.stringof);
    assert(V is null);          // not OK for frop1
    assert(__traits(getMember, this, VS) is null); // not OK for frop1
  }
  void zoo(alias V)() {
    writeln("zoo: ", V.stringof);
    assert(V is null);          // not OK for frop1
  }
  void goo(string VS)() {
    writeln("goo: ", __traits(getMember, this, VS).stringof);
    assert(__traits(getMember, this, VS) is null);
  }
  void setup() {
    assert(frop0 is null);
    moo!(frop0, "frop0")(this);
    moo!(frop1, "frop1")(this);
    boo!(frop0, "frop0")();
    goo!("frop0");
    goo!("frop1");
    zoo!(frop0)();
    zoo!(frop1)();      // segfault with LDC -- does not compile with DMD
    boo!(frop0, "frop0")();
    boo!(frop1, "frop1")();     // segfault with LDC -- does not compile with
DMD
  }
}

void moo(alias V, string VS, L)(L l) {
  import std.stdio;
  writeln("moo: ", __traits(getMember, l, VS).stringof);
  writeln("moo: ", V.stringof);
  assert(V is null); // OK
  assert(__traits(getMember, l, VS) is null); // OK
}

void main() {
  Bar bar = new Bar();
  bar.setup();
}

--
Oct 28 2019