susantohendra / cppclean

Automatically exported from code.google.com/p/cppclean
0 stars 0 forks source link

Unneeded-internal-declaration for variable that is used. #7

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
In some code if you have an internal variable that is used for a default 
argument, cppclean says it's not needed.  E.g.:

static const char foo[] = "blablabla";

void f(const char * cstr = foo){}

int main()
{  
  f();
  return 0;
}

What is the expected output? What do you see instead?
I expect cppclean to have no problems with this.  Instead it says:
clean_test.C:1: unused variable 'foo'

What version of the product are you using? On what operating system?
I am using cppclean 0.2.5, on Mac OSX 10.9.5.

Please provide any additional information below.
clang++ with -Wextra (but not with just -Wall) also complains that the variable 
is not needed.
It's possible I'm misunderstanding what the warning is trying to tell me.  I am 
interpreting "not needed" as "you could delete this line and it wouldn't break 
anything".  Clearly removing that line does break the code (I even tried it 
with clang++ just to be sure).

Original issue reported on code.google.com by jfcar...@gmail.com on 12 Nov 2014 at 11:27

GoogleCodeExporter commented 8 years ago
I have started using cppcheck, and it also does not warn about these lines.  I 
think this is a bug in cppclean.

Original comment by jfcar...@gmail.com on 2 Feb 2015 at 9:09