-Wshadow is silly about this piece of code: --------------------------------- class Foo { int bar_; public: void bar(int bar) { bar_ = bar; } }; --------------------------------- This is a fairly common style. Note that local and member variable have names that differ by the underscore. Yet: g/x> c++ -Wshadow -c x.cc x.cc: In member function 'void Foo::bar(int)': x.cc:5: warning: declaration of 'bar' shadows a member of 'this' I think that's being overly pedantic. W.
Note also that the documentation plainly states: @item -Wshadow @opindex Wshadow @opindex Wno-shadow Warn whenever a local variable shadows another local variable, parameter or global variable or whenever a built-in function is shadowed. The current behavior could therefore simply be classified as a bug. W.
bar the function shadows bar the variable. I think the warning is correct. The variable _bar is not being taken into account at all.
(In reply to comment #2) > bar the function shadows bar the variable. I think the warning is correct. > The variable _bar is not being taken into account at all. Ah, bummer, I didn't even look close enough to see that the function and its argument are named the same. Silly me, I just saw this piece of code another project was unhappy about and thought I should submit this as a bug. You're right, and I agree that the warning is valid. W.