From 70ed6b47f952bacd37d69a39c6fe122e7668cb49 Mon Sep 17 00:00:00 2001 From: fanquake Date: Wed, 13 Oct 2021 11:30:47 +0800 Subject: [PATCH 1/3] Merge bitcoin/bitcoin#23149: build: make --enable-werror just -Werror 38fd709fa5b7a01f149a65efdfe1a6b463477e4e build: make --enable-werror just -Werror (fanquake) Pull request description: No longer special case a set of warnings, to make up our own -Werror, just use -Werror outright. This shouldn't really have any effect on existing builders, who were already using `--enable-werror`, and is more inline with what they would expect `--enable-werror` to be, which is erroring on any/all warnings. We keep `-Wno-error=return-type` because we know that is broken when using mingw-w64. It should only be applied when cross-compiling for Windows. Similar to the change in #20544, but with (hopefully) less work-arounds, and other bundled changes. A step towards some configure "cleanups". ACKs for top commit: hebasto: ACK 38fd709fa5b7a01f149a65efdfe1a6b463477e4e (also see https://github.com/bitcoin/bitcoin/pull/23149#issuecomment-940420776), tested: MarcoFalke: Concept ACK 38fd709fa5b7a01f149a65efdfe1a6b463477e4e Tree-SHA512: 37f1857d9408442cab63e40f9280427b73e09cdf03146b19c1339d7e44abd78e93df7f270ca1da0e83b79343cd3ea915f7b9e4e347488b5bc5ceaaa7540e5926 --- configure.ac | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/configure.ac b/configure.ac index ca19fa8b6f30..3102a6d7cc95 100644 --- a/configure.ac +++ b/configure.ac @@ -322,7 +322,7 @@ AC_ARG_ENABLE([gprof], dnl Turn warnings into errors AC_ARG_ENABLE([werror], [AS_HELP_STRING([--enable-werror], - [Treat certain compiler warnings as errors (default is no)])], + [Treat compiler warnings as errors (default is no)])], [enable_werror=$enableval], [enable_werror=no]) @@ -450,32 +450,13 @@ if test "x$enable_werror" = "xyes"; then if test "x$CXXFLAG_WERROR" = "x"; then AC_MSG_ERROR("enable-werror set but -Werror is not usable") fi - AX_CHECK_COMPILE_FLAG([-Werror=reorder],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=reorder"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=gnu],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=gnu"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=shadow-field],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=shadow-field"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=switch],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=switch"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=thread-safety],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=range-loop-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=range-loop-analysis"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]]) + ERROR_CXXFLAGS=$CXXFLAG_WERROR dnl -Wreturn-type is broken in GCC for MinGW-w64. dnl https://sourceforge.net/p/mingw-w64/bugs/306/ - AX_CHECK_COMPILE_FLAG([-Werror=return-type], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"], [], [$CXXFLAG_WERROR], + AX_CHECK_COMPILE_FLAG([-Werror=return-type], [], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-error=return-type"], [$CXXFLAG_WERROR], [AC_LANG_SOURCE([[#include int f(){ assert(false); }]])]) - - AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Wsuggest-override], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"], [], [$CXXFLAG_WERROR]) - AX_CHECK_COMPILE_FLAG([-Werror=unreachable-code-loop-increment],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]]) - AX_CHECK_COMPILE_FLAG([-Werror=mismatched-tags], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=mismatched-tags"], [], [$CXXFLAG_WERROR]) - AX_CHECK_COMPILE_FLAG([-Werror=implicit-fallthrough], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=implicit-fallthrough"], [], [$CXXFLAG_WERROR]) - - if test x$suppress_external_warnings != xno ; then - AX_CHECK_COMPILE_FLAG([-Werror=documentation],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=documentation"],,[[$CXXFLAG_WERROR]]) - fi fi if test "x$CXXFLAGS_overridden" = "xno"; then @@ -484,6 +465,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wgnu],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wgnu"],,[[$CXXFLAG_WERROR]]) dnl some compilers will ignore -Wformat-security without -Wformat, so just combine the two here. AX_CHECK_COMPILE_FLAG([-Wformat -Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat -Wformat-security"],,[[$CXXFLAG_WERROR]]) + AX_CHECK_COMPILE_FLAG([-Wreorder],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wreorder"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wshadow-field],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-field"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wthread-safety],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]]) @@ -496,6 +478,8 @@ if test "x$CXXFLAGS_overridden" = "xno"; then AX_CHECK_COMPILE_FLAG([-Wduplicated-cond],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wduplicated-cond"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Wlogical-op],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wlogical-op"],,[[$CXXFLAG_WERROR]]) AX_CHECK_COMPILE_FLAG([-Woverloaded-virtual],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Woverloaded-virtual"],,[[$CXXFLAG_WERROR]]) + dnl -Wsuggest-override is broken with GCC before 9.2 + dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010 AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]], [AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])]) AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]]) From 8af10d7ac30e7ccab129083406c8b9a466e443af Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 24 Feb 2025 13:37:47 +0700 Subject: [PATCH 2/3] fix: warning with C++20 and gcc compiler --- src/qt/appearancewidget.cpp | 10 +++++----- src/qt/bitcoingui.cpp | 8 ++++---- src/qt/optionsdialog.cpp | 10 +++++----- src/qt/overviewpage.cpp | 2 +- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/qt/appearancewidget.cpp b/src/qt/appearancewidget.cpp index d52c03971a9b..2a26902d017a 100644 --- a/src/qt/appearancewidget.cpp +++ b/src/qt/appearancewidget.cpp @@ -46,11 +46,11 @@ AppearanceWidget::AppearanceWidget(QWidget* parent) : connect(ui->fontWeightNormalSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightNormal(nValue); }); connect(ui->fontWeightBoldSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightBold(nValue); }); - connect(ui->theme, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontFamily, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontScaleSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontWeightNormalSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); }); - connect(ui->fontWeightBoldSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); }); + connect(ui->theme, &QComboBox::currentTextChanged, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontFamily, &QComboBox::currentTextChanged, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontScaleSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontWeightNormalSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); }); + connect(ui->fontWeightBoldSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); }); } AppearanceWidget::~AppearanceWidget() diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 2628bdf3afad..36609e80684b 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -240,7 +240,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle, bool fDebugCustomStyleSheets = gArgs.GetBoolArg("-debug-ui", false) && GUIUtil::isStyleSheetDirectoryCustom(); if (fDebugCustomStyleSheets) { timerCustomCss = new QTimer(this); - QObject::connect(timerCustomCss, &QTimer::timeout, [=]() { + QObject::connect(timerCustomCss, &QTimer::timeout, [this]() { if (!m_node.shutdownRequested()) { GUIUtil::loadStyleSheet(); } @@ -291,7 +291,7 @@ void BitcoinGUI::startSpinner() }; timerSpinner = new QTimer(this); - QObject::connect(timerSpinner, &QTimer::timeout, [=]() { + QObject::connect(timerSpinner, &QTimer::timeout, [this, getNextFrame]() { if (timerSpinner == nullptr) { return; } @@ -319,7 +319,7 @@ void BitcoinGUI::startConnectingAnimation() } timerConnecting = new QTimer(this); - QObject::connect(timerConnecting, &QTimer::timeout, [=]() { + QObject::connect(timerConnecting, &QTimer::timeout, [this]() { if (timerConnecting == nullptr) { return; @@ -1353,7 +1353,7 @@ void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab) connect(dlg, &OptionsDialog::quitOnReset, this, &BitcoinGUI::quitRequested); dlg->setCurrentTab(tab); dlg->setModel(clientModel->getOptionsModel()); - connect(dlg, &OptionsDialog::appearanceChanged, [=]() { + connect(dlg, &OptionsDialog::appearanceChanged, [this]() { updateWidth(); }); GUIUtil::ShowModalDialogAndDeleteOnClose(dlg); diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 903daba278af..28fd6de091de 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -194,7 +194,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) : appearanceLayout->addWidget(appearance); ui->widgetAppearance->setLayout(appearanceLayout); - connect(appearance, &AppearanceWidget::appearanceChanged, [=](){ + connect(appearance, &AppearanceWidget::appearanceChanged, [this](){ updateWidth(); Q_EMIT appearanceChanged(); }); @@ -277,13 +277,13 @@ void OptionsDialog::setModel(OptionsModel *_model) connect(ui->lang, qOverload<>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); }); connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); }); - connect(ui->coinJoinEnabled, &QCheckBox::clicked, [=](bool fChecked) { + connect(ui->coinJoinEnabled, &QCheckBox::clicked, [this](bool fChecked) { #ifdef ENABLE_WALLET model->node().coinJoinOptions().setEnabled(fChecked); #endif updateCoinJoinVisibility(); - if (_model != nullptr) { - _model->emitCoinJoinEnabledChanged(); + if (this->model != nullptr) { + this->model->emitCoinJoinEnabledChanged(); } updateWidth(); }); @@ -293,7 +293,7 @@ void OptionsDialog::setModel(OptionsModel *_model) // Store the current CoinJoin enabled state to recover it if it gets changed but the dialog gets not accepted but declined. #ifdef ENABLE_WALLET fCoinJoinEnabledPrev = model->node().coinJoinOptions().isEnabled(); - connect(this, &OptionsDialog::rejected, [=]() { + connect(this, &OptionsDialog::rejected, [this]() { if (fCoinJoinEnabledPrev != model->node().coinJoinOptions().isEnabled()) { ui->coinJoinEnabled->click(); } diff --git a/src/qt/overviewpage.cpp b/src/qt/overviewpage.cpp index 6b9ace3144df..6f9a92438d48 100644 --- a/src/qt/overviewpage.cpp +++ b/src/qt/overviewpage.cpp @@ -328,7 +328,7 @@ void OverviewPage::setWalletModel(WalletModel *model) connect(model->getOptionsModel(), &OptionsModel::coinJoinRoundsChanged, this, &OverviewPage::updateCoinJoinProgress); connect(model->getOptionsModel(), &OptionsModel::coinJoinAmountChanged, this, &OverviewPage::updateCoinJoinProgress); connect(model->getOptionsModel(), &OptionsModel::AdvancedCJUIChanged, this, &OverviewPage::updateAdvancedCJUI); - connect(model->getOptionsModel(), &OptionsModel::coinJoinEnabledChanged, [=]() { + connect(model->getOptionsModel(), &OptionsModel::coinJoinEnabledChanged, [this]() { coinJoinStatus(true); }); From 2c4f77b8f1b5e00ea54215a605f8e3f3125f2a78 Mon Sep 17 00:00:00 2001 From: Konstantin Akimov Date: Mon, 24 Feb 2025 20:37:36 +0700 Subject: [PATCH 3/3] fix: disable stringop-overread for gcc11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This workaround let enable -Werror -Wall on our CI, otherwise compilation of uint256.h fails with this error: In member function ‘constexpr int base_blob::Compare(const base_blob&) const [with unsigned int BITS = 256]’, inlined from ‘constexpr bool operator!=(const base_blob<256>&, const base_blob<256>&)’ at ./uint256.h:58:96, inlined from ‘bool CDeterministicMNManager::BuildNewListFromBlock(const CBlock&, gsl::not_null, BlockValidationState&, const CCoinsViewCache&, CDeterministicMNList&, llmq::CQuorumSnapshotManager&, bool)’ at evo/deterministicmns.cpp:818:119: ./uint256.h:55:77: error: ‘int __builtin_memcmp_eq(const void*, const void*, long unsigned int)’ specified bound 32 exceeds source size 0 [-Werror=stringop-overread] 55 | constexpr int Compare(const base_blob& other) const { return std::memcmp(m_data.data(), other.m_data.data(), WIDTH); } | ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1plus: all warnings being treated as errors --- configure.ac | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/configure.ac b/configure.ac index 3102a6d7cc95..61a67d82d671 100644 --- a/configure.ac +++ b/configure.ac @@ -457,6 +457,15 @@ if test "x$enable_werror" = "xyes"; then AX_CHECK_COMPILE_FLAG([-Werror=return-type], [], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-error=return-type"], [$CXXFLAG_WERROR], [AC_LANG_SOURCE([[#include int f(){ assert(false); }]])]) + dnl -Wstringop-overread is broken in GCC 11. + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([[]], + [[#if __GNUC__ == 11 + #error -Wstringop-overread is broken in GCC 11 + #endif + ]])], + [], + [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-stringop-overread"]) fi if test "x$CXXFLAGS_overridden" = "xno"; then