Tips from the compiler

Rainer Deyke rainerd at eldwood.com
Tue Oct 19 01:03:49 PDT 2010


On 10/19/2010 01:31, Don wrote:
> It's not obvious to me how that can be done in the presence of
> templates. Although it's easy to distinguish between library and
> non-library *files*, it's not at all easy to distinguish between library
> and non-library *code*.

Simple.  If the template is in a library file, it's library code,
regardless of where it was instantiated.  Rationale:
  - If the warning is triggered on every instantiation of the template,
then it's obviously the library's problem.
  - If the warning is triggered on only some template instantiations,
the warning is probably spurious.  Template instantiations often
generate code that would look wrong in isolation, but is actually correct.
  - If you really want to catch those extra warnings, you can always
turn on warnings for library code and shift through the results.

You could add a compiler option to enable warning on templates in
library code if the template was instantiated in user code, but I
personally don't see the point.


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list