Jump to page: 1 214  
Page
Thread overview
Wish: Variable Not Used Warning
Jul 05, 2008
Nick Sabalausky
Jul 05, 2008
Koroskin Denis
Jul 06, 2008
bearophile
Jul 06, 2008
Nick Sabalausky
Jul 06, 2008
Nick Sabalausky
Jul 06, 2008
Ary Borenszweig
Jul 06, 2008
Walter Bright
Jul 06, 2008
Nick Sabalausky
Jul 06, 2008
Koroskin Denis
Jul 06, 2008
Nick Sabalausky
Jul 06, 2008
Robert Fraser
Jul 06, 2008
Walter Bright
Jul 06, 2008
Robert Fraser
Jul 08, 2008
Walter Bright
Jul 08, 2008
Nick Sabalausky
Jul 08, 2008
Walter Bright
Jul 09, 2008
Davidson Corry
Jul 10, 2008
Markus Koskimies
Jul 10, 2008
Markus Koskimies
Jul 10, 2008
bearophile
Jul 10, 2008
Markus Koskimies
Jul 10, 2008
Nick Sabalausky
Jul 10, 2008
Nick Sabalausky
Jul 10, 2008
Markus Koskimies
Jul 11, 2008
Nick Sabalausky
Jul 08, 2008
Sean Kelly
Jul 08, 2008
Sean Kelly
Jul 06, 2008
Nick Sabalausky
Jul 09, 2008
Walter Bright
Jul 09, 2008
dennis luehring
Jul 09, 2008
Nick Sabalausky
Jul 09, 2008
Nick Sabalausky
Jul 09, 2008
Bill Baxter
Jul 27, 2008
Bruno Medeiros
Jul 09, 2008
Walter Bright
Jul 09, 2008
Nick Sabalausky
Jul 09, 2008
Walter Bright
Jul 09, 2008
BCS
Jul 09, 2008
TomD
Jul 09, 2008
BCS
Jul 09, 2008
Bill Baxter
Jul 09, 2008
BCS
Jul 09, 2008
superdan
Jul 09, 2008
superdan
Jul 09, 2008
Nick Sabalausky
Jul 10, 2008
superdan
Jul 10, 2008
Walter Bright
Jul 10, 2008
Nick Sabalausky
Jul 10, 2008
superdan
Jul 11, 2008
Don
Jul 11, 2008
superdan
Jul 11, 2008
Robert Fraser
Jul 11, 2008
superdan
Jul 11, 2008
Bill Baxter
Jul 11, 2008
superdan
Jul 27, 2008
Bruno Medeiros
Jul 11, 2008
Robert Fraser
Jul 11, 2008
superdan
Jul 11, 2008
Markus Koskimies
Jul 10, 2008
Markus Koskimies
Jul 10, 2008
Nick Sabalausky
Jul 10, 2008
Markus Koskimies
Jul 11, 2008
Nick Sabalausky
Jul 11, 2008
Markus Koskimies
Jul 09, 2008
Nick Sabalausky
Jul 09, 2008
Walter Bright
Jul 09, 2008
Sean Kelly
Jul 09, 2008
Nick Sabalausky
Jul 10, 2008
Bruce Adams
Jul 10, 2008
Markus Koskimies
Jul 10, 2008
Leandro Lucarella
Jul 10, 2008
Bill Baxter
Jul 11, 2008
Nick Sabalausky
Jul 11, 2008
Markus Koskimies
Jul 27, 2008
Bruno Medeiros
Jul 27, 2008
Bruno Medeiros
Jul 28, 2008
Jussi Jumppanen
Jul 28, 2008
Robert Fraser
Jul 28, 2008
Bill Baxter
Jul 28, 2008
Robert Fraser
Jul 28, 2008
Bill Baxter
Jul 28, 2008
Robert Fraser
Jul 29, 2008
Yigal Chripun
Jul 28, 2008
Paul D. Anderson
Jul 29, 2008
Don
Jul 30, 2008
Bruno Medeiros
Jul 29, 2008
Jussi Jumppanen
Jul 28, 2008
Ary Borenszweig
Jul 09, 2008
Walter Bright
Jul 09, 2008
Koroskin Denis
Jul 09, 2008
bearophile
Jul 09, 2008
Koroskin Denis
Jul 09, 2008
Manfred_Nowak
Jul 09, 2008
Koroskin Denis
Jul 09, 2008
Manfred_Nowak
Jul 09, 2008
Nick Sabalausky
Jul 10, 2008
Manfred_Nowak
Jul 09, 2008
Matti Niemenmaa
Jul 09, 2008
Manfred_Nowak
Jul 10, 2008
Bruce Adams
Jul 10, 2008
Don
Jul 10, 2008
Bruce Adams
Jul 11, 2008
Don
Jul 11, 2008
Walter Bright
Jul 14, 2008
Don
Jul 09, 2008
Manfred_Nowak
Jul 09, 2008
Nick Sabalausky
Jul 09, 2008
Walter Bright
Jul 09, 2008
Nick Sabalausky
Jul 09, 2008
Walter Bright
Aug 05, 2008
Manfred_Nowak
Jul 07, 2008
Don
Jul 07, 2008
Don
Jul 09, 2008
Bruce Adams
Jul 09, 2008
Don
Jul 10, 2008
Bruce Adams
Jul 10, 2008
JAnderson
Jul 10, 2008
Manfred_Nowak
Jul 10, 2008
JAnderson
Jul 10, 2008
JAnderson
Jul 10, 2008
Bruce Adams
Jul 11, 2008
Markus Koskimies
Jul 27, 2008
Bruno Medeiros
Jul 27, 2008
Koroskin Denis
Jul 27, 2008
bearophile
Jul 27, 2008
Bruno Medeiros
Jul 27, 2008
Yigal Chripun
Jul 27, 2008
Bruno Medeiros
Jul 09, 2008
Manfred_Nowak
Jul 09, 2008
Nick Sabalausky
Jul 09, 2008
BCS
Jul 09, 2008
Nick Sabalausky
Jul 10, 2008
Walter Bright
July 05, 2008
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.


July 05, 2008
On Sun, 06 Jul 2008 03:34:52 +0400, Nick Sabalausky <a@a.a> 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.
>
>

Agreed, put it into a bugzilla, otherwise it may get lost.

Since D has no warnings, it should be an error, but it would break too much of the existing code.
Better solution might be to enable this check when compiling with -w...
July 06, 2008
Koroskin Denis:
> Agreed, put it into a bugzilla, otherwise it may get lost.

I have written this too in one of my lists of suggestions I have posted in this newsgroup, probably more than one year ago :-)


> Since D has no warnings, it should be an error, but it would break too much of the existing code.

What's bad about warnings?

Bye,
bearophile
July 06, 2008
"bearophile" <bearophileHUGS@lycos.com> wrote in message news:g4p207$24dk$1@digitalmars.com...
> Koroskin Denis:
>> Agreed, put it into a bugzilla, otherwise it may get lost.
>
> I have written this too in one of my lists of suggestions I have posted in this newsgroup, probably more than one year ago :-)
>
>
>> Since D has no warnings, it should be an error, but it would break too much of the existing code.
>
> What's bad about warnings?
>

Walter doesn't like them. He feels (felt?) that they tend to reflect shortcomings in a language's design (And I think there are many cases where he's right on that, looking at some other languages). But awhile ago he was finally convinced to put in some warnings when the "-w" flag is used. There was much rejoicing.


July 06, 2008
Well, I think the problems center around the following:

1. In many cases a "warning" in some C/C++ compilers really should be an error.  The line seems to be difficult and arguable.

2. Compilers don't agree on warnings.  This is sorta #1 but for those who ignore warnings, it means their code might (surprisingly to them) be non-portable.

3. Warnings beg warning suppressions methodologies, because they are sometimes made incorrectly (otherwise they'd be an error, no?)

4. It creates more of a rift between people who are pedantic about warnings, etc. and people who are not.  In my experience at least, maintenance programmers, newer programmers, and experienced programmers can all fit into those two groups in awkward ways.

A lot of these points are well expressed by PHP's (imho very flawed) error reporting.  Most PHP programmers learn to turn warnings off before they even learn what a for loop is.  I've taken many large open-source or proprietary PHP codebases, simply turned on warnings, and been able to point out a handful of very obvious bugs in short order.

I think breaking it like D does is an excellent strategy based on real world, practical problems with warnings.

In any case, I would very much like to see (or develop) a code-standards enforcing lint tool for D.  This wouldn't be that hard to make based on dmd's open source frontend, and could be configured to enforce such guidelines as:

1. No commented out code (WebKit uses this guideline, I do with some languages as well.)

2. Either consistent or specific indentation style.

3. Variable usage and naming.

4. Use of unstable, deprecated, or untrusted language or library features.

But I really think that works better as a separate tool (that could be a checkin hook for whatever preferred versioning system, etc.)  This helps especially since some people don't compile things (although they should) before checkin, and actually recompiling automatically is often wrong.

-[Unknown]


bearophile wrote:
> Koroskin Denis:
>> Agreed, put it into a bugzilla, otherwise it may get lost.
> 
> I have written this too in one of my lists of suggestions I have posted in this newsgroup, probably more than one year ago :-)
> 
> 
>> Since D has no warnings, it should be an error, but it would break too  much of the existing code.
> 
> What's bad about warnings?
> 
> Bye,
> bearophile
July 06, 2008
Nick Sabalausky a écrit :
> 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. 

Moreover, I'd like a warning when a private variable is declared but never read. And when a private method is declared but never invoked.
July 06, 2008
"Koroskin Denis" <2korden@gmail.com> wrote in message news:op.uduer8uhenyajd@korden...
> On Sun, 06 Jul 2008 03:34:52 +0400, Nick Sabalausky <a@a.a> 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.
>>
>>
>
> Agreed, put it into a bugzilla, otherwise it may get lost.
>
> Since D has no warnings, it should be an error, but it would break too
> much of the existing code.
> Better solution might be to enable this check when compiling with -w...

Added as issue #2197 http://d.puremagic.com/issues/show_bug.cgi?id=2197


July 06, 2008
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. 

The problem with unused variable warnings is they are annoying when you're developing code in an iterative manner. They get in the way when you're commenting out sections of code to try and isolate a problem. They can be a problem when using "version" and "static if" statements.

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. If you're faced with compiling someone else's code (like you downloaded it off the internet and have to compile it because it only is distributed as source) and warnings go off, is that a bug in the code or not? What do you do?

Some shops have a "thou shall compile with warnings enabled, and there shall be no warning messages." That causes problems when you port the code to a different compiler with a different, even contradictory, notion of what is a warning. So then you wind up putting wacky things in the code just to get the compiler to shut up about the warnings.

Those kind of things tend to interfere with the beauty of the code, and since they are not necessary to the program's logic, they tend to confuse and misdirect the maintenance programmer (why is this variable pointlessly referenced here? Why is this unreachable return statement here? Is this a bug?)

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.
July 06, 2008
"Walter Bright" <newshound1@digitalmars.com> wrote in message news:g4pplc$gno$1@digitalmars.com...
> 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.
>
> The problem with unused variable warnings is they are annoying when you're developing code in an iterative manner. They get in the way when you're commenting out sections of code to try and isolate a problem. They can be a problem when using "version" and "static if" statements.
>

I develop code in a highly iterative manner and find "unused variable" warnings highly useful. In all of the time I've spent with other compilers that do issue "unused variable" warnings, I've never found it to be an annoyance. And the way I've always seen it, warnings literally *are* a built-in lint tool.


July 06, 2008
On Sun, 06 Jul 2008 10:45:03 +0400, Walter Bright <newshound1@digitalmars.com> 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.
>
> The problem with unused variable warnings is they are annoying when you're developing code in an iterative manner. They get in the way when you're commenting out sections of code to try and isolate a problem. They can be a problem when using "version" and "static if" statements.
>
> 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. If you're faced with compiling someone else's code (like you downloaded it off the internet and have to compile it because it only is distributed as source) and warnings go off, is that a bug in the code or not? What do you do?
>
> Some shops have a "thou shall compile with warnings enabled, and there shall be no warning messages." That causes problems when you port the code to a different compiler with a different, even contradictory, notion of what is a warning. So then you wind up putting wacky things in the code just to get the compiler to shut up about the warnings.
>
> Those kind of things tend to interfere with the beauty of the code, and since they are not necessary to the program's logic, they tend to confuse and misdirect the maintenance programmer (why is this variable pointlessly referenced here? Why is this unreachable return statement here? Is this a bug?)
>
> 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.

Since DMD already has -w switch, why not make use of it? I think it would be a good practice to compile your code with -w on just once in a while, say, before a public release. This should enable more strick code checking, like unused methods, variables, unreachable code etc.
« First   ‹ Prev
1 2 3 4 5 6 7 8 9 10 11