Can anyone provide an example of how D templates are overridable by global symbols?

Siarhei Siamashka siarhei.siamashka at gmail.com
Fri Jan 28 23:01:41 UTC 2022


On Thursday, 27 January 2022 at 21:50:12 UTC, kinke wrote:
> An example:
>
> [...]
>
> Now if the calls are inlined, the behavior might not be 
> consistent anymore. So separate compilations with different 
> compiler flags can cause observable differences.

Thanks! This was very informative. Though I'm not convinced that 
having a single (but randomly chosen) function used across the 
whole program is much better than a random mix of multiple 
versions. Especially if (unlike your example) this function 
doesn't identify itself in a user visible way. Both cases are 
bad, one is just much worse than the other.

Internet seems to disagree about what happens when multiple weak 
symbols are encountered and various interpretations can be found: 
"Given multiple weak symbols, choose any of the weak symbols", 
"if there exists several weak symbols, GCC will choose one that 
have the largest size (memory occupation)", etc. And I'm not 
inclined to happily rely on either of these opinions.


More information about the Digitalmars-d-learn mailing list