Can anyone provide an example of how D templates are overridable by global symbols?
siarhei.siamashka at gmail.com
Thu Dec 9 20:53:52 UTC 2021
A quote of Iain Buclaw from
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102765 about GDC
> D semantics for template symbols is that they must be
> overridable - even by normal global symbols.
> So in version 11.1, the default linkage for templates was
> switched over to weak, and with that, you can't safely inline
> them without violating ODR.
My (most likely wrong) interpretation of this is that the D
language standard somehow makes it impossible to make template
inlining decisions at the compilation stage and this job has to
be delegated to the linker. And as a result, the use of LTO
becomes required for generating fast binaries. Another
implication is that fast incremental rebuilds of optimized
binaries are likely highly problematic.
So I have two questions:
1. What is the exact wording of the D language standard on this
2. How would one construct a simple example of a template
symbol getting successfully overridden by a global symbol?
More information about the Digitalmars-d-learn