December 30, 2021
https://issues.dlang.org/show_bug.cgi?id=22638

          Issue ID: 22638
           Summary: [ICE] cod4.d: Assertion `cast(int)sz > 0' failed
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody@puremagic.com
          Reporter: tim.dlang@t-online.de

extern(C++) struct S
{
    this(ref const(S));
    ~this();
}

struct AutoRefWrapper(T) if(is(T == class))
{
    private T obj;
    template opDispatch(string name)
    {
        auto opDispatch(Params...)(auto ref Params params)
        {
            return __traits(getMember, obj, name)(params);
        }
    }
}

extern(C++) class C
{
    final void setS(ref const S);
    final void setS(const S s)
    {
        setS(s);
    }
}

void main()
{
    C c;
    AutoRefWrapper!C(c).setS(S());
}

Compiling the above code with dmd results in an assertion failure on Linux
x86_64:
dmd: src/dmd/backend/cod4.d:424: Assertion `cast(int)sz > 0' failed.

--