Thread overview
[Issue 20458] CRTP + pass alias to virtual member to mixin = runtime crash
Dec 17, 2022
Iain Buclaw
Mar 22, 2023
Basile-z
Mar 22, 2023
Basile-z
Mar 23, 2023
Basile-z
Mar 23, 2023
Basile-z
December 19, 2019
https://issues.dlang.org/show_bug.cgi?id=20458

hsteoh@quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh@quickfur.ath.cx

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=20458

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
March 22, 2023
https://issues.dlang.org/show_bug.cgi?id=20458

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #1 from Basile-z <b2.temp@gmx.com> ---
With assertions built in DMD your code triggers this :
https://github.com/dlang/dmd/blob/498822ec8efb8e2b68e257b01fa1e097ec6e3a88/compiler/src/dmd/dsymbolsem.d#L5261,
so the vtbl seems to be started already, probably with "test" but then is
rebuild again, without

--
March 22, 2023
https://issues.dlang.org/show_bug.cgi?id=20458

--- Comment #2 from Basile-z <b2.temp@gmx.com> ---
reduced further

```
mixin template Impl(T){
    alias a =  __traits(getMember, T, "test");
    //alias a = T.test; // no vtbl corruption with this alias
}

class A(T) {
    mixin Impl!T;
}

class Foo : A!Foo {
    void test() {}
}

void main() {
    (new Foo).test();
}
```

--
March 23, 2023
https://issues.dlang.org/show_bug.cgi?id=20458

--- Comment #3 from Basile-z <b2.temp@gmx.com> ---
The same corruption without the getMember trait:

```
mixin template Impl(T){
    alias a = T.test;
    pragma(msg, typeof(a)); // launch dsymbolsema and corrupt vtbl
}

class A(T) {
    mixin Impl!T;
}

class Foo : A!Foo {
    void test() {}
}

void main() {
    (new Foo).test();
}
```

--
March 23, 2023
https://issues.dlang.org/show_bug.cgi?id=20458

--- Comment #4 from Basile-z <b2.temp@gmx.com> ---
Finally the generic reproduction

```
class Base
{
    alias a = Derived.test;
    pragma(msg, typeof(a)); // triggers the vtbl corruption
}

class Derived : Base
{
    void test(){}
}

void main()
{
    (new Derived).test();
}
```

--