Are templates required ?

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Jan 19 03:41:20 PST 2007


Anders F Björklund wrote:
> Are templates an optional feature of D 1.0,
> or are they required by any implementation ?
> 
> Reason I ask is because they *don't* work OK
> with Mac OS X 10.3 (or 10.2) version of GDC
> that I did using GCC 3.x because the compiler
> doesn't have "one-only linkage" that is required.
> 
> Most of Phobos and D programs work anyway, using
> the -femit-templates parameter set to "private",
> but for more complex programs this tends to fail.
> (DMDScript and readf being two such examples...)
> 
> The Mac OS X 10.4 GDC version has no such problems,
> so if it is required I'll just drop Panther support.

I'd say it's required to be fully compliant to the spec. However, I 
don't think it's necessarily sufficient reason to deny the other 
benefits of D to users of an old toolchain.

How does g++ fix this, by the way? C++ has templates, so it should be 
possible. Or does that also fail for 'more complex programs'?


And in what way would "private" template emission fail, anyway? It might 
cause extra bloat but I can't see how it would fail?

After some more thinking:
Though comparing addresses of template instances might be problematic. 
And value types whose hash depends on an address (function pointers and 
delegates for instance) might then cause problems with associative 
arrays if the address points to a template instantiated from multiple 
modules...


Something else about the original problem: Would it maybe be possible to 
backport once-only linkage to the old GCC? Or would that be a lot of work?



More information about the Digitalmars-d mailing list