Wish: Variable Not Used Warning

Walter Bright newshound1 at digitalmars.com
Tue Jul 8 14:40:26 PDT 2008


Nick Sabalausky wrote:
> Ok, so the different warnings should be able to be turned on and off. If you 
> don't agree with a particular type of warning then you turn it off. That's 
> the nice thing about warnings as opposed to errors: they're optionally 
> letting you know about certain conditions that you might want to be aware 
> of, and they do it without changing, redefining, or otherwise affecting the 
> language itself.

That situation exists today for C++ compilers, and it's not so good. You 
have, as I mentioned previously, n factorial different languages instead 
of 1. Portability becomes a problem. Confusion about whether the code 
should compile or not reigns.

>> If it was in the compiler, it would inhibit development of static analysis 
>> tools,
> Can you elaborate on how this would happen?

It's the same reason why "m4" never caught on as a C preprocessor, 
despite being vastly superior, and despite everyone who wanted a better 
CPP being told to use m4.


>> and would confuse the issue of what was correct D code.
> 
> Anything that generates a warning instead of an error is by definition valid 
> code. If it wasn't valid it would generate an error instead of a warning.

That's true, but it is not what happens in the real world with warnings. 
I've dealt with warnings on C/C++ compilers for 25 years, and the 
practice is very different from the theory.



More information about the Digitalmars-d mailing list