Bug 21235 – Undefined reference with circular opEquals between two templates, one of which has an error
Status
RESOLVED
Resolution
DUPLICATE
Severity
regression
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-09-10T13:41:13Z
Last change time
2020-09-14T09:29:51Z
Keywords
industry, link-failure
Assigned to
No Owner
Creator
FeepingCreature
Comments
Comment #0 by default_357-line — 2020-09-10T13:41:13Z
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
Comment #1 by default_357-line — 2020-09-10T13:47:53Z
Simplification.
```
struct Template {
void opEquals(U, this TA)(U) {
pragma(msg, "Template.opEquals!(" ~ U.stringof ~ ", " ~ TA.stringof ~ ")");
foo();
}
}
void foo()() {
static assert(false); // we never even compile this.
return Template().opEquals(Template()); // but this is still needed
}
void main() { }
```
Comment #2 by default_357-line — 2020-09-10T13:51:47Z
This may be a duplicate of https://issues.dlang.org/show_bug.cgi?id=19091 . It smells similar, but I'm not certain. The `opEquals` seems to add a unique touch here, but they may have a common cause.
Comment #3 by default_357-line — 2020-09-14T09:29:51Z
Definitely the same bug as 19091.
*** This issue has been marked as a duplicate of issue 19091 ***