On Fri, Nov 08, 2013 at 06:31:25PM -0600, Tom Browder wrote:
I am trying to use Boost 1.54.0 to replace a previous version (1.47) and am using g++ 4.7 with most warnings turned on. I am getting many -Wshadow errors and wonder why they exist. Surely the developers test for such.
Warning-free code is a pipe dream, particularly if you target an open-ended set of compilers and compiler versions. Sure, it'd be "nice" if there were no warnings from third party code, but it's often detrimental to cover the code in warts that serve no actual purpose but to silence warnings, whether it's casting away return values, SAL-like annotations, etc.
Here is one example from xpressive/detail/utility/hash_peek_bitset.hpp:
Both 'icase' and 'count' are reported to shadow members of 'this'.
isn't good practice IMHO to do such so that is why I like to use some
"Good practice" gets you deep into bikeshedding real quick. I'd say it's _more_ bug-prone if an author strays too far from his comfort zone in projects where it's not required.
I could file many bugs but it begs the question of why the warnings are allowed in the first place.
Different people have different conventions for things like member functions. In this case, the author seems to be a fan of the "access any members via this" approach, where it's perfectly fine to have shadowing. If the whole reason for this hubbub is because you're one of those folks that use -Werror, it's your responsibility to tune your set of warnings to rule out the ones that cause excessive false positives. Warnings are not errors for a reason, they exist as advice that may or may not apply. -- Lars Viklund | zao@acc.umu.se