Tips from the compiler

Rainer Deyke rainerd at eldwood.com
Tue Oct 19 18:31:22 PDT 2010


On 10/19/2010 18:20, Don wrote:
> Example: Suppose we have warnings for possible numeric overflow. Then
> consider:
> sort!"a*5<b"(x);
> We should have a warning that 'a*5' may cause a numeric overflow. How
> can that be done?

I'm not convinced that we should have a warning here.  Validating
template arguments is the 'sort' template's job.  If the argument
validates, then the compiler should accept it as valid unless it leads
to an actual error during compilation.  If this causes some valid
warnings to be lost, so be it.  It beats the alternative of forcing
library authors to write warning-free code.

If you are really paranoid, there's always the option of generating
warnings on all template instantiations triggered (directly or
indirectly) by user code.  It can and will lead to spurious warnings,
but that's the price you pay for paranoia.


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list