D-Scanner
D-Scanner copied to clipboard
False positive "unused var"
Using IntelliJ Idea with Dscanner I get a tip: "Variable foo is never used"
void test()
{
int foo;
{
foo = 1;
}
}
What did you use foo for in this example?
To clarify: If I removed all lines referencing foo
from that function, what would change?
Ok, I misunderstood error message. The message says "not used" but i thought that "foo = 1" was an usage. Maybe it is "unread" :)
So this wasn't an issue ?
I think it is. Other ides report this warning as "never read".
Yes but "never used" is not a false positive.
Imo this is an unused var:
{ int a; ... }
In previous example it is used (assigned) but never read.
Finding variables that are written to but never read is one of the purposes of this check. I'm tempted to close this as not a bug.