On 3/26/2011 7:10 PM, bearophile wrote:
The optimizer removes those as "dead assignments", so no value is computed
needlessly or expensively.
The point of those warnings is NOT to improve code/compiler optimizations,
but just to help programmers catch their bugs better.

You quoted a claim saying it was also an optimization.


A nice paper, "Using Redundancies to Find Errors", by Yichen Xie and Dawson
Engler, 2002: http://www.stanford.edu/~engler/p401-xie.pdf

It shows that most programmers don't put deliberatively redundancies in their
programs, like assigning a value to a variable and never reading it again (in
all code paths). When this happens in programs, frequently that's a bug of
the programmer. So catching unused variables, or variables set and then never
read is a good way to catch programmers bugs.

As I said, these kinds of error messages are very annoying when developing code, for example, when enabling and disabling various sections.


GCC designers, C# compiler designers, a known lint designers, that paper (and
my personal experience in C) tell the same story. A way to automatically find
unused variables is good in the compiler. I think it's not easy for you to
confute them all :-)

I get told I'm wrong on just about everything I do.

Reply via email to