Subject: Re: [Boost-bugs] [Boost C++ Libraries] #9378: g++ 4.7 -Wshadow warnings need attention
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-19 02:55:23
#9378: g++ 4.7 -Wshadow warnings need attention
------------------------------------------+--------------------------
Reporter: Tom Browder <tom.browder@â¦> | Owner: eric_niebler
Type: Bugs | Status: new
Milestone: To Be Determined | Component: xpressive
Version: Boost 1.55.0 | Severity: Problem
Resolution: | Keywords:
------------------------------------------+--------------------------
Comment (by rmann@â¦):
I mean you don't need any special knowledge of what the code is doing to
go through and modify variable names to avoid shadowing, if you understand
how the compiler resolves scope. Sure, looking at the code, it's obvious
which variable is being referenced. What's not obvious is if that was the
intent of the programmer of that code.
Why do you think the warning exists at all? if there is no danger to
shadowing variables, why does any compiler anywhere support warning you?
The answer is that there IS a danger in doing so. Explicit naming, on the
other hand, reduces the likelihood that one will accidentally reference
the wrong variable, since the NAME is different. You won't be thinking
"foo" when what you really meant was "mFoo" (or "foo_" or whatever style
you choose).
Turning off the warning, by any means is sticking your head in the sand
and hoping there's nothing wrong. The headers are hacky because you have
to litter your code with them. They're a bandaid on the real problem,
which is code full of warnings.
If you want to shadow variables in your own code, that's one thing. But
code that's used by thousands of others should be free of warnings in the
bulk of the compilers it supports.
I clearly can't convince you of the benefit of having warning-free code,
shadow or otherwise. It certainly reduces my confidence in Boost being a
robust product.
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/9378#comment:12> Boost C++ Libraries <http://www.boost.org/> Boost provides free peer-reviewed portable C++ source libraries.
This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC