-
Notifications
You must be signed in to change notification settings - Fork 38.7k
Wshadow: various gcc fixes #9911
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
gcc version 5.3.1 20160301 [gcc-5-branch revision 233849] is completely |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK (lightly reviewed)
|
Any reason this is split into three commits with mostly the same
commit messages?
…On Sat, Mar 4, 2017 at 8:40 PM, Gregory Maxwell ***@***.***> wrote:
@gmaxwell commented on this pull request.
utACK
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
|
Yes. It is WIP. I'm adding commit by commit for various gcc/clang version I test so people do not see warnings. I still have to test one more clang version I have installed on one system. Wil squash afterwards of course. |
|
BTW, this PR is open also for others who see some |
|
Sigh, more Wshadow changes. Is this ever done? |
b43439c to
279c29d
Compare
|
... and squashed as both clang version tested are
|
Aside: In my case, yes. FreeBSD defaults to clang nowadays, and on Linux I use clang specifically for Bitcoin Core because it compiles faster and uses less memory (=more parallelism with same amount of RAM). GCC is supposed to produce slightly better code for x86 though, or at least that used to be the case years ago. So for production builds it makes sense to use that (which we do in gitian). I think @theuni was discussing switching all the builds to clang at some point though because it makes cross-compiling easier (also clang support for Win32 is supposed to be fairly good, whereas GCC is giving us a lot of trouble recently.) But it's not possible to say generally that one of them is better. |
dcousens
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
utACK
279c29d to
bfc6be9
Compare
|
Added fix for #8574's local variable redeclaration (aka shadowing). For easier searching, here is the log: |
|
paveljanik have you compiled with a make clean lately? I'm flooded with streams.h:407:44: warning: declaration of ‘data’ shadows a member of 'this' [-Wshadow] |
|
@gmaxwell This should be already fixed in this PR - https://github.com/bitcoin/bitcoin/pull/9911/files#diff-eb3b977a68473a9d20093cbe90c659e6L407 BTW - I always clean compile... |
|
utACK bfc6be9 |
src/torcontrol.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this shadowing? (and can we make it static?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With gcc4.8.5:
bitcoin@linux-5bz0:~/bitcoin> make CC=gcc
Making all in src
make[1]: Entering directory '/home/bitcoin/bitcoin/src'
make[2]: Entering directory '/home/bitcoin/bitcoin/src'
CXX libbitcoin_server_a-torcontrol.o
/usr/include/boost/date_time/time_system_counted.hpp: In instantiation of 'static boost::date_time::counted_time_system<time_rep>::time_rep_type boost::date_time::counted_time_system<time_rep>::add_days(const time_rep_type&, const date_duration_type&) [with time_rep = boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config>; boost::date_time::counted_time_system<time_rep>::time_rep_type = boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config>; boost::date_time::counted_time_system<time_rep>::date_duration_type = boost::gregorian::date_duration]':
/usr/include/boost/date_time/time.hpp:141:45: required from 'boost::date_time::base_time<T, time_system>::time_type boost::date_time::base_time<T, time_system>::operator+(const date_duration_type&) const [with T = boost::posix_time::ptime; time_system = boost::date_time::counted_time_system<boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config> >; boost::date_time::base_time<T, time_system>::time_type = boost::posix_time::ptime; boost::date_time::base_time<T, time_system>::date_duration_type = boost::gregorian::date_duration]'
/usr/include/boost/date_time/posix_time/date_duration_operators.hpp:33:37: required from here
torcontrol.cpp:665:20: warning: shadowed declaration is here [-Wshadow]
struct event_base *base;
^
/usr/include/boost/date_time/time_system_counted.hpp: In instantiation of 'static boost::date_time::counted_time_system<time_rep>::time_rep_type boost::date_time::counted_time_system<time_rep>::add_time_duration(const time_rep_type&, boost::date_time::counted_time_system<time_rep>::time_duration_type) [with time_rep = boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config>; boost::date_time::counted_time_system<time_rep>::time_rep_type = boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config>; boost::date_time::counted_time_system<time_rep>::time_duration_type = boost::posix_time::time_duration]':
/usr/include/boost/date_time/time.hpp:161:64: required from 'boost::date_time::base_time<T, time_system>::time_type boost::date_time::base_time<T, time_system>::operator+(const time_duration_type&) const [with T = boost::posix_time::ptime; time_system = boost::date_time::counted_time_system<boost::date_time::counted_time_rep<boost::posix_time::millisec_posix_time_system_config> >; boost::date_time::base_time<T, time_system>::time_type = boost::posix_time::ptime; boost::date_time::base_time<T, time_system>::time_duration_type = boost::posix_time::time_duration]'
/usr/include/boost/date_time/posix_time/conversion.hpp:30:48: required from here
torcontrol.cpp:665:20: warning: shadowed declaration is here [-Wshadow]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, that doesnt really answer my question, thanks gcc...Is that trying to say that boost has some "base" object that we're shadowing? Either way lets make the new gBase static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. I do not see any base there 8)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh no, so we're at renaming random variables now without even understanding why just to shut up warnings.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are overreacting. The problem is elsewhere, of course. The original author is using base all over the source code and arguments of methods conflicts with the global (now static). I think that renaming the global and making it static is the best solution here. Yes, discovered because of turning on -Wshadow.
|
To be honest I'd prefer to disable -Wshadow again. Even a few days after enabling it, it seems to me it requires too many disjointed, seemingly random changes, and continuous maintenance after almost every thing that gets merged after new incomprehensible warnings pop up with some gcc or clang version. |
|
We might keep it enabled, after all it could help to detect valid
bugs. Though, I agree that those "fix various gcc warnings" with no
apparent rationale other than "The warning disappears when compiling
with this specific version of boost and gcc-x.x.x" are not
particularly helpful. (I am not against all changes in this pull, but
we should only commit the fixes that make sense and keep the commits
itself at a frequency that does not hinder the other development
work.)
…On Wed, Mar 8, 2017 at 10:15 PM, Wladimir J. van der Laan ***@***.***> wrote:
To be honest I'd prefer to disable -Wshadow again. Even a few days after enabling it, it seems to me it requires too many disjointed, seemingly random changes, and continuous maintenance after almost every thing that gets merged after new incomprehensible warnings pop up with some gcc or clang version.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
It could, sure. In an ideal situation where compilers had a single, sane (or even close) definition of shadowing I'd be all for it. Also changes in boost or other dependencies could suddenly trigger these in our code. E.g. on the version of boost on FreeBSD I see various warnings inside boost too. |
|
@gmaxwell noted that there are also sub-options for Wshadow. Maybe we can reduce the false positives/weird cases this way. |
|
We had some false positive/weird case? The |
5396531 to
8de5159
Compare
|
Rebased. |
|
@laanwj Can you please upload your FreeBSD build log for me with V=1 so I can investigate your warnings? |
8de5159 to
0cebfcf
Compare
|
Added fix for #9497's shadowing issues: |
83fedab to
d7f80b6
Compare
|
@paveljanik thanks, going to re-check.
You are right, it's just that in the interest of reducing friction (efficient checking) and eliminating the chance of accidental bugs introduced in these pulls we should require identical binaries. |
d7f80b6 Rename first iterator to prevent shadowing. (Pavel Janík) b42ff60 Fix shadowing of local variables. (Pavel Janík) c4b60b3 Make some global variables less-global (static) (Pavel Janík) bb2aaee Prevent -Wshadow warnings with gcc versions 4.8.5, 5.3.1 and 6.2.1. (Pavel Janík) Tree-SHA512: 3aea4e28146c8f2a31351c6e2b0cce88b6f1e567a0ea0e6131624453e7193d0904e30d81b1439d8c69e281cf0e369b895851fb882ae48d5967b5c2e2c227404e
Tor ephemeral hidden services Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6503 (included to reduce merge conflicts) - bitcoin/bitcoin#6639 - bitcoin/bitcoin#6643 - bitcoin/bitcoin#7090 - bitcoin/bitcoin#7035 - bitcoin/bitcoin#7170 - bitcoin/bitcoin#7218 (non-QT part) - bitcoin/bitcoin#7313 - bitcoin/bitcoin#7438 - bitcoin/bitcoin#7553 - bitcoin/bitcoin#7637 - bitcoin/bitcoin#7683 - bitcoin/bitcoin#7813 - bitcoin/bitcoin#7703 - bitcoin/bitcoin#8203 - bitcoin/bitcoin#9004 - bitcoin/bitcoin#9234 - bitcoin/bitcoin#9911 (partial) Closes #2061.
This warning was enabled by default in bitcoin#8808 but it's a [continuing](bitcoin#9911 (comment)) [source](bitcoin#10089 (comment)) of [annoyance](bitcoin#9911 (comment)) for me and other developers. I'm sick of sounding like a broken record, so disable it again.
d7f80b6 Rename first iterator to prevent shadowing. (Pavel Janík) b42ff60 Fix shadowing of local variables. (Pavel Janík) c4b60b3 Make some global variables less-global (static) (Pavel Janík) bb2aaee Prevent -Wshadow warnings with gcc versions 4.8.5, 5.3.1 and 6.2.1. (Pavel Janík) Tree-SHA512: 3aea4e28146c8f2a31351c6e2b0cce88b6f1e567a0ea0e6131624453e7193d0904e30d81b1439d8c69e281cf0e369b895851fb882ae48d5967b5c2e2c227404e
Additional
-Wshadowfixes for gcc 4.8.5.