[Issue 20795] New: [dip1000] segfault on templated opEquals

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun May 3 17:38:06 UTC 2020


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

          Issue ID: 20795
           Summary: [dip1000] segfault on templated opEquals
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: mail at skoppe.eu

Compile following with `dmd -dip1000` and you get a segfault in
dmd.func.FuncDeclaration.setUnsafe().

It has been reduced with dustmite so the code might not make sense. If the
opEquals in Bar is converted from template to regular function we get a good
error message, same with the opCast in Bar. 

---
import std;

alias NamedArg = Tuple!Bar;

struct Foo
{
        VariantN!24 variant;

        bool opEquals(T)(T rhs) {
                variant.opEquals(rhs);
        }
}

struct Bar
{
        bool opEquals()(Bar )
        {
                return Gun() == Foo.init;
        }
}

class Baz {
        T opCast(T)()
        {
        }
}

struct Gun
{
        void[24] buff;

        auto underlying()       {
                return cast(Baz)buff.ptr;
        }

        alias underlying this;
}
---

--


More information about the Digitalmars-d-bugs mailing list