Wish: Variable Not Used Warning
JAnderson
ask at me.com
Wed Jul 9 22:57:48 PDT 2008
Walter Bright wrote:
> Nick Sabalausky wrote:
>> I don't suppose there's any chance of DMD getting a warning for
>> variables/arguments that are declared but never accessed? Just today
>> alone there's been two bugs I spent 10-30 minutes going nuts trying to
>> track down that turned out to be variables I had intended to use but
>> forgot to.
>
> So, why not just turn off the warnings?
>
> The problem with warnings is that if there are n warnings, there are
> essentially n factorial different versions of the language. <Snip>
> There is a place for warnings, however. That is in a separate static
> analysis tool (i.e. lint, coverity, etc.) which can be armed with all
> kinds of heuristics with which to flag questionable constructs. I don't
> think they should be part of the compiler, however.
Something like lint can be run and have a consistent output on every D
compiler and platform since it doesn't care about building the actual
platform specific code. Having no warnings in the compiler means you
can't have hardware/platform specific warnings. And I think thats great.
Personally in C++ I like to turn to warning level 4 with warnings as
errors and run both a GCC and a MSVC++ compile (when working on multiple
platforms). Most warnings can removed without use of pragma and using
both compilers gives a much better coverage of warnings.
I'm personally a fan of catching things early. The more warnings as
errors the better. If I have to suffer a little for false positives
*shrug* however its much better then spending hours in a mud pit full of
crocodiles; that is debugging.
-Joel
More information about the Digitalmars-d
mailing list