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
build: Enable some commonly enabled compiler diagnostics #19015
Conversation
Concept ACK, but before merge we should check that there are no warnings. This includes warnings in headers of third-party libraries. Boost and Qt have a good track record of producing warnings. |
Concept ACK. |
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
Enable unreachable-code-loop-increment and treat as error. refs: bitcoin#19015
eea8114 build: Enable unreachable-code-loop-increment (Jonathan Schoeller) d15db4b refactor: Fix unreachable code in init arg checks (Jonathan Schoeller) Pull request description: Closes: #19017 In #19015 it's been suggested that we add some new compiler warnings to our build. Some of these, such as `-Wunreachable-code-loop-increment`, generate warnings. We'll likely want to fix these up if we're going to turn these warnings on. ```shell init.cpp:969:5: warning: loop will run at most once (loop increment never executed) [-Wunreachable-code-loop-increment] for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) { ^~~ 1 warning generated. ``` https://github.com/bitcoin/bitcoin/blob/aa8d76806c74a51ec66e5004394fe9ea8ff0fac4/src/init.cpp#L968-L972 To fix this, collect all errors, and output them in a single error message after the loop completes. This resolves the unreachable code warning, and avoids popup hell that could result from outputting a seperate message for each error or warning one by one. ACKs for top commit: laanwj: Code review ACK eea8114 hebasto: re-ACK eea8114, only suggested changes applied since the [previous](#19131 (review)) review. Tree-SHA512: 2aa3ceb7fab581b6ba2580900668388d8eba1c3001c8ff9c11c1f4a9a10fbc37f30e590249862676858446e3f4950140a252953ba1643ba3bfd772f8eae20583
@practicalswift Why this PR does not include changes to get rid of new warnings? master (39afe5b) + this PR:
|
eea8114 build: Enable unreachable-code-loop-increment (Jonathan Schoeller) d15db4b refactor: Fix unreachable code in init arg checks (Jonathan Schoeller) Pull request description: Closes: bitcoin#19017 In bitcoin#19015 it's been suggested that we add some new compiler warnings to our build. Some of these, such as `-Wunreachable-code-loop-increment`, generate warnings. We'll likely want to fix these up if we're going to turn these warnings on. ```shell init.cpp:969:5: warning: loop will run at most once (loop increment never executed) [-Wunreachable-code-loop-increment] for (const auto& arg : gArgs.GetUnsuitableSectionOnlyArgs()) { ^~~ 1 warning generated. ``` https://github.com/bitcoin/bitcoin/blob/aa8d76806c74a51ec66e5004394fe9ea8ff0fac4/src/init.cpp#L968-L972 To fix this, collect all errors, and output them in a single error message after the loop completes. This resolves the unreachable code warning, and avoids popup hell that could result from outputting a seperate message for each error or warning one by one. ACKs for top commit: laanwj: Code review ACK eea8114 hebasto: re-ACK eea8114, only suggested changes applied since the [previous](bitcoin#19131 (review)) review. Tree-SHA512: 2aa3ceb7fab581b6ba2580900668388d8eba1c3001c8ff9c11c1f4a9a10fbc37f30e590249862676858446e3f4950140a252953ba1643ba3bfd772f8eae20583
@hebasto Thanks for testing! I wanted to keep this PR build-system only to keep review simple. Feel free to tackle the warnings in a separate PR if you want :) |
@MarcoFalke I don't think this one needs rebase - anything else that you had in mind with the "waiting for author" label? :) |
|
9d54881
to
7547a27
Compare
@MarcoFalke Oh, thanks for clarifying! Now fixed :) |
The Travis TSan job failure is unrelated but I'm unable to re-run the job :) |
Another rebase would make it rerun |
7547a27
to
f573cc2
Compare
Enable unreachable-code-loop-increment and treat as error. refs: bitcoin#19015
Concept ACK
There's not really a rush to do this, and it's unlikely this will be merged while it introduces any new (presumably easy to fix?) warnings. So if we're going to turn new diagnostics on, let's just take care of any warnings now, or, if you'd rather not deal with code changes, please reduce the scope of this PR. I checked out this branch and started building. Spamming the log with the following is not going to be useful, and in this case it's coming from the brew installed Boost: Options used to compile and link:
multiprocess = no
with wallet = yes
with gui / qt = yes
with qr = yes
with zmq = yes
with test = yes
with fuzz = no
with bench = yes
with upnp = yes
use asm = yes
sanitizers =
debug enabled = no
gprof enabled = no
werror = no
target os = darwin
build os = darwin19.6.0
CC = /usr/local/bin/ccache gcc
CFLAGS = -g -O2
CPPFLAGS = -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -DHAVE_BUILD_INFO -D__STDC_FORMAT_MACROS -I/usr/local/opt/berkeley-db@4/include -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0
CXX = /usr/local/bin/ccache g++ -std=c++11
CXXFLAGS = -Wstack-protector -fstack-protector-all -Wall -Wextra -Wgnu -Wformat -Wvla -Wshadow-field -Wswitch -Wformat-security -Wthread-safety -Wrange-loop-analysis -Wredundant-decls -Wunused-variable -Wdate-time -Wconditional-uninitialized -Wsign-compare -Woverloaded-virtual -Wunused-member-function -Wunused-template -Wunreachable-code-loop-increment -Wno-unused-parameter -Wno-self-assign -Wno-unused-local-typedef -Wno-deprecated-register -Wno-implicit-fallthrough -g -O2
LDFLAGS = -pthread -Wl,-bind_at_load -Wl,-headerpad_max_install_names -Wl,-dead_strip -Wl,-dead_strip_dylibs
ARFLAGS = cr
/Applications/Xcode.app/Contents/Developer/usr/bin/make -C src bitcoind
CXX bitcoind-bitcoind.o
CXX libbitcoin_server_a-addrdb.o
CXX libbitcoin_server_a-addrman.o
CXX libbitcoin_server_a-banman.o
CXX libbitcoin_server_a-blockencodings.o
CXX libbitcoin_server_a-blockfilter.o
CXX libbitcoin_server_a-chain.o
CXX libbitcoin_server_a-flatfile.o
CXX libbitcoin_server_a-httprpc.o
CXX libbitcoin_server_a-httpserver.o
CXX libbitcoin_server_a-init.o
CXX libbitcoin_server_a-dbwrapper.o
CXX libbitcoin_server_a-miner.o
CXX libbitcoin_server_a-net.o
CXX libbitcoin_server_a-net_processing.o
In file included from blockencodings.cpp:13:
In file included from ./txmempool.h:26:
In file included from /usr/local/include/boost/multi_index_container.hpp:32:
In file included from /usr/local/include/boost/multi_index_container_fwd.hpp:19:
In file included from /usr/local/include/boost/multi_index/ordered_index_fwd.hpp:16:
In file included from /usr/local/include/boost/multi_index/detail/ord_index_args.hpp:21:
In file included from /usr/local/include/boost/multi_index/tag.hpp:17:
In file included from /usr/local/include/boost/multi_index/detail/no_duplicate_tags.hpp:18:
In file included from /usr/local/include/boost/mpl/set/set0.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/at_impl.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/has_key_impl.hpp:21:
In file included from /usr/local/include/boost/mpl/aux_/overload_names.hpp:17:
/usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
template< typename T > static T const& ptr_to_ref(T*);
^
1 warning generated.
CXX libbitcoin_server_a-noui.o
CXX libbitcoin_server_a-pow.o
CXX libbitcoin_server_a-rest.o
CXX libbitcoin_server_a-shutdown.o
CXX libbitcoin_server_a-timedata.o
CXX libbitcoin_server_a-torcontrol.o
CXX libbitcoin_server_a-txdb.o
In file included from miner.cpp:6:
In file included from ./miner.h:11:
In file included from ./txmempool.h:26:
In file included from /usr/local/include/boost/multi_index_container.hpp:32:
In file included from /usr/local/include/boost/multi_index_container_fwd.hpp:19:
In file included from /usr/local/include/boost/multi_index/ordered_index_fwd.hpp:16:
In file included from /usr/local/include/boost/multi_index/detail/ord_index_args.hpp:21:
In file included from /usr/local/include/boost/multi_index/tag.hpp:17:
In file included from /usr/local/include/boost/multi_index/detail/no_duplicate_tags.hpp:18:
In file included from /usr/local/include/boost/mpl/set/set0.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/at_impl.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/has_key_impl.hpp:21:
In file included from /usr/local/include/boost/mpl/aux_/overload_names.hpp:17:
/usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
template< typename T > static T const& ptr_to_ref(T*);
^
1 warning generated.
CXX libbitcoin_server_a-txmempool.o
CXX libbitcoin_server_a-ui_interface.o
CXX libbitcoin_server_a-validation.o
In file included from rest.cpp:19:
In file included from ./txmempool.h:26:
In file included from /usr/local/include/boost/multi_index_container.hpp:32:
In file included from /usr/local/include/boost/multi_index_container_fwd.hpp:19:
In file included from /usr/local/include/boost/multi_index/ordered_index_fwd.hpp:16:
In file included from /usr/local/include/boost/multi_index/detail/ord_index_args.hpp:21:
In file included from /usr/local/include/boost/multi_index/tag.hpp:17:
In file included from /usr/local/include/boost/multi_index/detail/no_duplicate_tags.hpp:18:
In file included from /usr/local/include/boost/mpl/set/set0.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/at_impl.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/has_key_impl.hpp:21:
In file included from /usr/local/include/boost/mpl/aux_/overload_names.hpp:17:
/usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
template< typename T > static T const& ptr_to_ref(T*);
^
1 warning generated.
CXX libbitcoin_server_a-validationinterface.o
CXX libbitcoin_server_a-versionbits.o
CXX interfaces/libbitcoin_wallet_a-wallet.o
CXX wallet/libbitcoin_wallet_a-coincontrol.o
In file included from txmempool.cpp:6:
In file included from ./txmempool.h:26:
In file included from /usr/local/include/boost/multi_index_container.hpp:32:
In file included from /usr/local/include/boost/multi_index_container_fwd.hpp:19:
In file included from /usr/local/include/boost/multi_index/ordered_index_fwd.hpp:16:
In file included from /usr/local/include/boost/multi_index/detail/ord_index_args.hpp:21:
In file included from /usr/local/include/boost/multi_index/tag.hpp:17:
In file included from /usr/local/include/boost/multi_index/detail/no_duplicate_tags.hpp:18:
In file included from /usr/local/include/boost/mpl/set/set0.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/at_impl.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/has_key_impl.hpp:21:
In file included from /usr/local/include/boost/mpl/aux_/overload_names.hpp:17:
/usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
template< typename T > static T const& ptr_to_ref(T*);
^
1 warning generated.
CXX wallet/libbitcoin_wallet_a-context.o
CXX wallet/libbitcoin_wallet_a-crypter.o
CXX wallet/libbitcoin_wallet_a-db.o
In file included from init.cpp:28:
In file included from ./miner.h:11:
In file included from ./txmempool.h:26:
In file included from /usr/local/include/boost/multi_index_container.hpp:32:
In file included from /usr/local/include/boost/multi_index_container_fwd.hpp:19:
In file included from /usr/local/include/boost/multi_index/ordered_index_fwd.hpp:16:
In file included from /usr/local/include/boost/multi_index/detail/ord_index_args.hpp:21:
In file included from /usr/local/include/boost/multi_index/tag.hpp:17:
In file included from /usr/local/include/boost/multi_index/detail/no_duplicate_tags.hpp:18:
In file included from /usr/local/include/boost/mpl/set/set0.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/at_impl.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/has_key_impl.hpp:21:
In file included from /usr/local/include/boost/mpl/aux_/overload_names.hpp:17:
/usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
template< typename T > static T const& ptr_to_ref(T*);
^
1 warning generated.
CXX wallet/libbitcoin_wallet_a-feebumper.o
CXX wallet/libbitcoin_wallet_a-fees.o
CXX wallet/libbitcoin_wallet_a-load.o
CXX wallet/libbitcoin_wallet_a-rpcdump.o
In file included from net_processing.cpp:16:
In file included from ./validation.h:22:
In file included from ./txmempool.h:26:
In file included from /usr/local/include/boost/multi_index_container.hpp:32:
In file included from /usr/local/include/boost/multi_index_container_fwd.hpp:19:
In file included from /usr/local/include/boost/multi_index/ordered_index_fwd.hpp:16:
In file included from /usr/local/include/boost/multi_index/detail/ord_index_args.hpp:21:
In file included from /usr/local/include/boost/multi_index/tag.hpp:17:
In file included from /usr/local/include/boost/multi_index/detail/no_duplicate_tags.hpp:18:
In file included from /usr/local/include/boost/mpl/set/set0.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/at_impl.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/has_key_impl.hpp:21:
In file included from /usr/local/include/boost/mpl/aux_/overload_names.hpp:17:
/usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
template< typename T > static T const& ptr_to_ref(T*);
^
1 warning generated.
> Killed build. |
@fanquake Thanks for testing, and your feedback makes sense: I'll adjust accordingly. I don't have any macOS machine to test on -- would you mind sharing the results of |
You should just be able to just check the Travis output: Making install in src
< snip >
CXX libbitcoin_server_a-init.o
In file included from blockencodings.cpp:13:
In file included from ./txmempool.h:26:
In file included from /usr/local/include/boost/multi_index_container.hpp:32:
In file included from /usr/local/include/boost/multi_index_container_fwd.hpp:19:
In file included from /usr/local/include/boost/multi_index/ordered_index_fwd.hpp:16:
In file included from /usr/local/include/boost/multi_index/detail/ord_index_args.hpp:21:
In file included from /usr/local/include/boost/multi_index/tag.hpp:17:
In file included from /usr/local/include/boost/multi_index/detail/no_duplicate_tags.hpp:18:
In file included from /usr/local/include/boost/mpl/set/set0.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/at_impl.hpp:18:
In file included from /usr/local/include/boost/mpl/set/aux_/has_key_impl.hpp:21:
In file included from /usr/local/include/boost/mpl/aux_/overload_names.hpp:17:
/usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
template< typename T > static T const& ptr_to_ref(T*);
^
1 warning generated.
12 /usr/local/Cellar/qt/5.15.0/lib/QtCore.framework/Headers/qtestsupport_core.h:55:31: warning: unused function template 'qWaitFor' [-Wunused-template]
137 /usr/local/include/boost/mpl/aux_/ptr_to_ref.hpp:42:40: warning: unused function template 'ptr_to_ref' [-Wunused-template]
1 index/blockfilterindex.cpp:54:5: warning: unused member function 'DBHeightKey' [-Wunused-member-function]
1 index/blockfilterindex.cpp:80:5: warning: unused function template 'Unser' [-Wunused-template]
1 index/blockfilterindex.cpp:80:5: warning: unused function template 'Unserialize' [-Wunused-template]
1 qt/bitcoin.cpp:259:53: warning: 'QFlags' is deprecated: Use default constructor instead [-Wdeprecated-declarations]
1 qt/bitcoingui.cpp:1304:29: warning: 'pixmap' is deprecated: Use the other overload which returns QPixmap by-value [-Wdeprecated-declarations]
1 qt/optionsmodel.cpp:222:59: warning: 'split' is deprecated: Use Qt::SplitBehavior variant instead [-Wdeprecated-declarations]
1 qt/qrimagewidget.cpp:100:12: warning: 'pixmap' is deprecated: Use the other overload which returns QPixmap by-value [-Wdeprecated-declarations]
1 qt/qrimagewidget.cpp:105:45: warning: 'pixmap' is deprecated: Use the other overload which returns QPixmap by-value [-Wdeprecated-declarations]
1 qt/qrimagewidget.cpp:121:9: warning: 'pixmap' is deprecated: Use the other overload which returns QPixmap by-value [-Wdeprecated-declarations]
1 qt/qrimagewidget.cpp:132:9: warning: 'pixmap' is deprecated: Use the other overload which returns QPixmap by-value [-Wdeprecated-declarations]
1 qt/qrimagewidget.cpp:139:9: warning: 'pixmap' is deprecated: Use the other overload which returns QPixmap by-value [-Wdeprecated-declarations]
1 qt/qrimagewidget.cpp:98:9: warning: 'pixmap' is deprecated: Use the other overload which returns QPixmap by-value [-Wdeprecated-declarations]
1 qt/sendcoinsdialog.cpp:174:72: warning: 'buttonClicked' is deprecated: Use QButtonGroup::idClicked(int) instead [-Wdeprecated-declarations]
1 qt/sendcoinsdialog.cpp:175:72: warning: 'buttonClicked' is deprecated: Use QButtonGroup::idClicked(int) instead [-Wdeprecated-declarations]
1 qt/transactionview.cpp:240:85: warning: 'split' is deprecated: Use Qt::SplitBehavior variant instead [-Wdeprecated-declarations]
1 qt/transactionview.cpp:278:17: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 qt/transactionview.cpp:285:17: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 qt/transactionview.cpp:291:17: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 qt/transactionview.cpp:296:17: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 qt/transactionview.cpp:297:17: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 qt/transactionview.cpp:301:17: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 qt/transactionview.cpp:586:13: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 qt/transactionview.cpp:587:13: warning: 'QDateTime' is deprecated: Use QDate::startOfDay() [-Wdeprecated-declarations]
1 random.cpp:257:13: warning: unused function 'GetDevURandom' [-Wunused-function]
2 script/bitcoinconsensus.cpp:50:9: warning: unused member function 'GetType' [-Wunused-member-function]
1 test/util_tests.cpp:1972:14: warning: unused member function 'operator=' [-Wunused-member-function] |
f573cc2
to
2f8a4c9
Compare
Oh, of course! Thanks! :) I've now updated the PR to only enable Should be ready for final review :) |
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.
ACK 2f8a4c9, no new warnings in Travis jobs.
Are there any reasons for not adding corresponding -Werror
?
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.
ACK 2f8a4c9 no warnings for me with these locally on debian 5.7.10-1 (2020-07-26) x86_64 with gcc 10 and clang 12
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.
ACK 2f8a4c9 - no-longer seeing any obvious issues with doing this.
…gnostics 2f8a4c9 build: Enable some commonly enabled compiler diagnostics (practicalswift) Pull request description: Enable some commonly enabled compiler diagnostics as discussed in bitcoin#17344. | Compiler diagnostic | no# of emitted unique GCC warnings in `master` | no# of emitted unique Clang warnings in `master` | | ------------- | ------------- | ------------- | | `-Wduplicated-branches`: Warn if `if`/`else` branches have duplicated code | 0 | Not supported | | `-Wduplicated-cond`: Warn if `if`/`else` chain has duplicated conditions | 0 | Not supported | | `-Wlogical-op`: Warn about logical operations being used where bitwise were probably wanted | 0 | Not supported | | `-Woverloaded-virtual`: Warn if you overload (not `override`) a virtual function | 0 | 0 | | ~~`-Wunused-member-function`: Warn on unused member function~~ | Not supported | 2 | | ~~`-Wunused-template`: Warn on unused template~~ | Not supported | 1 | There is a large overlap between this list and [Jason Turner's list of recommended compiler diagnostics in the Collaborative Collection of C++ Best Practices (`cppbestpractices`) project](https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md#gcc--clang). There is also an overlap with the recommendations given in the [C++ Core Guidelines](https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines) (with editors Bjarne Stroustrup and Herb Sutter). Closes bitcoin#17344. ACKs for top commit: jonatack: ACK 2f8a4c9 no warnings for me with these locally on debian 5.7.10-1 (2020-07-26) x86_64 with gcc 10 and clang 12 fanquake: ACK 2f8a4c9 - no-longer seeing any obvious issues with doing this. hebasto: ACK 2f8a4c9, no new warnings in Travis jobs. Tree-SHA512: f669ea22b31263a555f999eff6a9d65750662e95831b188c3192a2cf0127fb7b5136deb762a6b0b7bbdfb0dc6a40caf48251a62b164fffb81dd562bdd15ec3c8
A post-merge success story: only 21 days after merge
Thanks a lot for reporting @kristapsk! ❤️ Perhaps we should do |
Summary: > as discussed in [[ bitcoin/bitcoin#17344 | #17344]] > > There is a large overlap between this list and Jason Turner's list of recommended compiler diagnostics in the Collaborative Collection of C++ Best Practices (cppbestpractices) project. There is also an overlap with the recommendations given in the C++ Core Guidelines (with editors Bjarne Stroustrup and Herb Sutter). This is a backport of [[bitcoin/bitcoin#19015 | core#19015]] Disable `-Wduplicated-branches` for secp256k1, because of some exotic intentional use of ternary operator duplicated branches in test_inverse_scalar. Test Plan: ``` cmake .. -GNinja -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_C_FLAGS=-Werror ninja && ninja check && ninja check-secp256k1 rm -Rf * cmake .. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_C_FLAGS=-Werror ninja && ninja check && ninja check-secp256k1 ``` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D10113
Summary: > as discussed in [[ bitcoin/bitcoin#17344 | #17344]] > > There is a large overlap between this list and Jason Turner's list of recommended compiler diagnostics in the Collaborative Collection of C++ Best Practices (cppbestpractices) project. There is also an overlap with the recommendations given in the C++ Core Guidelines (with editors Bjarne Stroustrup and Herb Sutter). This is a backport of [[bitcoin/bitcoin#19015 | core#19015]] Disable `-Wduplicated-branches` for secp256k1, because of some exotic intentional use of ternary operator duplicated branches in test_inverse_scalar. Test Plan: ``` cmake .. -GNinja -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_C_FLAGS=-Werror ninja && ninja check && ninja check-secp256k1 rm -Rf * cmake .. -GNinja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_CXX_FLAGS=-Werror -DCMAKE_C_FLAGS=-Werror ninja && ninja check && ninja check-secp256k1 ``` Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D10113
Enable some commonly enabled compiler diagnostics as discussed in #17344.
master
master
-Wduplicated-branches
: Warn ifif
/else
branches have duplicated code-Wduplicated-cond
: Warn ifif
/else
chain has duplicated conditions-Wlogical-op
: Warn about logical operations being used where bitwise were probably wanted-Woverloaded-virtual
: Warn if you overload (notoverride
) a virtual function-Wunused-member-function
: Warn on unused member function-Wunused-template
: Warn on unused templateThere is a large overlap between this list and Jason Turner's list of recommended compiler diagnostics in the Collaborative Collection of C++ Best Practices (
cppbestpractices
) project. There is also an overlap with the recommendations given in the C++ Core Guidelines (with editors Bjarne Stroustrup and Herb Sutter).Closes #17344.