[Issue 24830] New: separate compilation + circular deps + templated opCmp = missing symbols
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 23 14:15:00 UTC 2024
https://issues.dlang.org/show_bug.cgi?id=24830
Issue ID: 24830
Summary: separate compilation + circular deps + templated opCmp
= missing symbols
Product: D
Version: D2
Hardware: x86_64
OS: Mac OS X
Status: NEW
Severity: normal
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: ilya.yanok at gmail.com
It's probably a rare case, but if I try to compile separately two modules that
are part of a dependency cycle, and both of them are instantiating a templated
struct that has a templated `opCmp` implementation (I think `opEquals` and
`toHash` are also affected), none of the resulting object files will contains
the code for the `opCmp` instantiation.
Example:
```d
// option.d
import util;
struct Option(T) {
private T _x;
int opCmp()(const(Option) rhs) const {
return 1;
}
}
Option!string p;
```
```d
// util.d
import option;
Option!string x;
```
This is happening because while compiling `option.d` the compiler thinks
`Option!string.opCmp!()` is instantiated in `util.d` and vice versa, so we end
up not having it at all.
--
More information about the Digitalmars-d-bugs
mailing list