www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21235] New: Undefined reference with circular opEquals

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

          Issue ID: 21235
           Summary: Undefined reference with circular opEquals between two
                    templates, one of which has an error
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: default_357-line yahoo.de

Consider the following code:

```
struct Template {
    bool opEquals(U, this TA)(U) {
        pragma(msg, "Template.opEquals!(" ~ U.stringof ~ ", " ~ TA.stringof ~
")");
        return Helper().opEquals(Helper());
    }
}

struct Helper {
    bool opEquals()(Helper) {
        static assert(false); // trigger some error here
        Template().opEquals(Template()); // circle back around
    }
}

void main() { }
```

With every DMD version **since 2.063**, and also git at v2.093.1-551-gec431149f
(master of 2020-09-10), this produces a linker error on simple compilation.

https://run.dlang.io/is/tiCXc4

--
Sep 10 2020