
* Lars Viklund
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.
Or they may, and any convention for managing shadowing applied to headers would trivially enable a coder to enable shadowing warnings on their own code. This potentially saves them mysterious bugs and sniffing around in a debugger before finding that it was something the compiler could have told them about if it weren't lost in the noise. I agree with not being religious about it, but -Wshadow is a pretty achievable goal.
-- Lars Viklund | zao@acc.umu.se _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
-- -ericP office: +1.617.599.3509 mobile: +33.6.80.80.35.59 (eric@w3.org) Feel free to forward this message to any list for any purpose other than email address distribution. There are subtle nuances encoded in font variation and clever layout which can only be seen by printing this message on high-clay paper.