Skip to content

Commit 00c1bf0

Browse files
Merge #6596: backport: Merge bitcoin#23149: build: make --enable-werror just -Werror
2c4f77b fix: disable stringop-overread for gcc11 (Konstantin Akimov) 8af10d7 fix: warning with C++20 and gcc compiler (Konstantin Akimov) 70ed6b4 Merge bitcoin#23149: build: make --enable-werror just -Werror (fanquake) Pull request description: ## What was done? Backport bitcoin#23149 introduced more strict list of warnings that are considered as compilation error. It caused several compilation errors, that has been addressed by this PR. It has been split to own PR for easier testing / debugging from #6577 ## How Has This Been Tested? It has been tested with clang 16.0.6 and gcc 13.2.0 No compilation errors. ## Breaking Changes N/A ## Checklist: - [x] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have added or updated relevant unit/integration/functional/e2e tests - [ ] I have made corresponding changes to the documentation - [x] I have assigned this pull request to a milestone _(for repository code-owners and collaborators only)_ ACKs for top commit: UdjinM6: ACK 2c4f77b kwvg: utACK 2c4f77b Tree-SHA512: d2799891f6c64e3d341a297aebd3b283b0b6be8daa393744cf4499911f635afcdde809771ee6c7267ce760306c5210eb217679982f4980b3c3964f7132614a27
2 parents a73024d + 2c4f77b commit 00c1bf0

File tree

5 files changed

+30
-37
lines changed

5 files changed

+30
-37
lines changed

configure.ac

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ AC_ARG_ENABLE([gprof],
322322
dnl Turn warnings into errors
323323
AC_ARG_ENABLE([werror],
324324
[AS_HELP_STRING([--enable-werror],
325-
[Treat certain compiler warnings as errors (default is no)])],
325+
[Treat compiler warnings as errors (default is no)])],
326326
[enable_werror=$enableval],
327327
[enable_werror=no])
328328

@@ -450,32 +450,22 @@ if test "x$enable_werror" = "xyes"; then
450450
if test "x$CXXFLAG_WERROR" = "x"; then
451451
AC_MSG_ERROR("enable-werror set but -Werror is not usable")
452452
fi
453-
AX_CHECK_COMPILE_FLAG([-Werror=reorder],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=reorder"],,[[$CXXFLAG_WERROR]])
454-
AX_CHECK_COMPILE_FLAG([-Werror=gnu],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=gnu"],,[[$CXXFLAG_WERROR]])
455-
AX_CHECK_COMPILE_FLAG([-Werror=vla],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=vla"],,[[$CXXFLAG_WERROR]])
456-
AX_CHECK_COMPILE_FLAG([-Werror=shadow-field],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=shadow-field"],,[[$CXXFLAG_WERROR]])
457-
AX_CHECK_COMPILE_FLAG([-Werror=switch],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=switch"],,[[$CXXFLAG_WERROR]])
458-
AX_CHECK_COMPILE_FLAG([-Werror=thread-safety],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=thread-safety"],,[[$CXXFLAG_WERROR]])
459-
AX_CHECK_COMPILE_FLAG([-Werror=range-loop-analysis],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=range-loop-analysis"],,[[$CXXFLAG_WERROR]])
460-
AX_CHECK_COMPILE_FLAG([-Werror=unused-variable],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unused-variable"],,[[$CXXFLAG_WERROR]])
461-
AX_CHECK_COMPILE_FLAG([-Werror=date-time],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=date-time"],,[[$CXXFLAG_WERROR]])
453+
ERROR_CXXFLAGS=$CXXFLAG_WERROR
462454

463455
dnl -Wreturn-type is broken in GCC for MinGW-w64.
464456
dnl https://sourceforge.net/p/mingw-w64/bugs/306/
465-
AX_CHECK_COMPILE_FLAG([-Werror=return-type], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=return-type"], [], [$CXXFLAG_WERROR],
457+
AX_CHECK_COMPILE_FLAG([-Werror=return-type], [], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-error=return-type"], [$CXXFLAG_WERROR],
466458
[AC_LANG_SOURCE([[#include <cassert>
467459
int f(){ assert(false); }]])])
468-
469-
AX_CHECK_COMPILE_FLAG([-Werror=conditional-uninitialized],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=conditional-uninitialized"],,[[$CXXFLAG_WERROR]])
470-
AX_CHECK_COMPILE_FLAG([-Werror=sign-compare],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=sign-compare"],,[[$CXXFLAG_WERROR]])
471-
AX_CHECK_COMPILE_FLAG([-Wsuggest-override], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"], [], [$CXXFLAG_WERROR])
472-
AX_CHECK_COMPILE_FLAG([-Werror=unreachable-code-loop-increment],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=unreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]])
473-
AX_CHECK_COMPILE_FLAG([-Werror=mismatched-tags], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=mismatched-tags"], [], [$CXXFLAG_WERROR])
474-
AX_CHECK_COMPILE_FLAG([-Werror=implicit-fallthrough], [ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=implicit-fallthrough"], [], [$CXXFLAG_WERROR])
475-
476-
if test x$suppress_external_warnings != xno ; then
477-
AX_CHECK_COMPILE_FLAG([-Werror=documentation],[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Werror=documentation"],,[[$CXXFLAG_WERROR]])
478-
fi
460+
dnl -Wstringop-overread is broken in GCC 11.
461+
AC_COMPILE_IFELSE(
462+
[AC_LANG_PROGRAM([[]],
463+
[[#if __GNUC__ == 11
464+
#error -Wstringop-overread is broken in GCC 11
465+
#endif
466+
]])],
467+
[],
468+
[ERROR_CXXFLAGS="$ERROR_CXXFLAGS -Wno-stringop-overread"])
479469
fi
480470

481471
if test "x$CXXFLAGS_overridden" = "xno"; then
@@ -484,6 +474,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
484474
AX_CHECK_COMPILE_FLAG([-Wgnu],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wgnu"],,[[$CXXFLAG_WERROR]])
485475
dnl some compilers will ignore -Wformat-security without -Wformat, so just combine the two here.
486476
AX_CHECK_COMPILE_FLAG([-Wformat -Wformat-security],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wformat -Wformat-security"],,[[$CXXFLAG_WERROR]])
477+
AX_CHECK_COMPILE_FLAG([-Wreorder],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wreorder"],,[[$CXXFLAG_WERROR]])
487478
AX_CHECK_COMPILE_FLAG([-Wvla],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wvla"],,[[$CXXFLAG_WERROR]])
488479
AX_CHECK_COMPILE_FLAG([-Wshadow-field],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wshadow-field"],,[[$CXXFLAG_WERROR]])
489480
AX_CHECK_COMPILE_FLAG([-Wthread-safety],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wthread-safety"],,[[$CXXFLAG_WERROR]])
@@ -496,6 +487,8 @@ if test "x$CXXFLAGS_overridden" = "xno"; then
496487
AX_CHECK_COMPILE_FLAG([-Wduplicated-cond],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wduplicated-cond"],,[[$CXXFLAG_WERROR]])
497488
AX_CHECK_COMPILE_FLAG([-Wlogical-op],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wlogical-op"],,[[$CXXFLAG_WERROR]])
498489
AX_CHECK_COMPILE_FLAG([-Woverloaded-virtual],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Woverloaded-virtual"],,[[$CXXFLAG_WERROR]])
490+
dnl -Wsuggest-override is broken with GCC before 9.2
491+
dnl https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78010
499492
AX_CHECK_COMPILE_FLAG([-Wsuggest-override],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wsuggest-override"],,[[$CXXFLAG_WERROR]],
500493
[AC_LANG_SOURCE([[struct A { virtual void f(); }; struct B : A { void f() final; };]])])
501494
AX_CHECK_COMPILE_FLAG([-Wunreachable-code-loop-increment],[WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code-loop-increment"],,[[$CXXFLAG_WERROR]])

src/qt/appearancewidget.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ AppearanceWidget::AppearanceWidget(QWidget* parent) :
4646
connect(ui->fontWeightNormalSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightNormal(nValue); });
4747
connect(ui->fontWeightBoldSlider, &QSlider::valueChanged, [this](auto nValue) { updateFontWeightBold(nValue); });
4848

49-
connect(ui->theme, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); });
50-
connect(ui->fontFamily, &QComboBox::currentTextChanged, [=]() { Q_EMIT appearanceChanged(); });
51-
connect(ui->fontScaleSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); });
52-
connect(ui->fontWeightNormalSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); });
53-
connect(ui->fontWeightBoldSlider, &QSlider::sliderReleased, [=]() { Q_EMIT appearanceChanged(); });
49+
connect(ui->theme, &QComboBox::currentTextChanged, [this]() { Q_EMIT appearanceChanged(); });
50+
connect(ui->fontFamily, &QComboBox::currentTextChanged, [this]() { Q_EMIT appearanceChanged(); });
51+
connect(ui->fontScaleSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); });
52+
connect(ui->fontWeightNormalSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); });
53+
connect(ui->fontWeightBoldSlider, &QSlider::sliderReleased, [this]() { Q_EMIT appearanceChanged(); });
5454
}
5555

5656
AppearanceWidget::~AppearanceWidget()

src/qt/bitcoingui.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ BitcoinGUI::BitcoinGUI(interfaces::Node& node, const NetworkStyle* networkStyle,
240240
bool fDebugCustomStyleSheets = gArgs.GetBoolArg("-debug-ui", false) && GUIUtil::isStyleSheetDirectoryCustom();
241241
if (fDebugCustomStyleSheets) {
242242
timerCustomCss = new QTimer(this);
243-
QObject::connect(timerCustomCss, &QTimer::timeout, [=]() {
243+
QObject::connect(timerCustomCss, &QTimer::timeout, [this]() {
244244
if (!m_node.shutdownRequested()) {
245245
GUIUtil::loadStyleSheet();
246246
}
@@ -291,7 +291,7 @@ void BitcoinGUI::startSpinner()
291291
};
292292

293293
timerSpinner = new QTimer(this);
294-
QObject::connect(timerSpinner, &QTimer::timeout, [=]() {
294+
QObject::connect(timerSpinner, &QTimer::timeout, [this, getNextFrame]() {
295295
if (timerSpinner == nullptr) {
296296
return;
297297
}
@@ -319,7 +319,7 @@ void BitcoinGUI::startConnectingAnimation()
319319
}
320320

321321
timerConnecting = new QTimer(this);
322-
QObject::connect(timerConnecting, &QTimer::timeout, [=]() {
322+
QObject::connect(timerConnecting, &QTimer::timeout, [this]() {
323323

324324
if (timerConnecting == nullptr) {
325325
return;
@@ -1353,7 +1353,7 @@ void BitcoinGUI::openOptionsDialogWithTab(OptionsDialog::Tab tab)
13531353
connect(dlg, &OptionsDialog::quitOnReset, this, &BitcoinGUI::quitRequested);
13541354
dlg->setCurrentTab(tab);
13551355
dlg->setModel(clientModel->getOptionsModel());
1356-
connect(dlg, &OptionsDialog::appearanceChanged, [=]() {
1356+
connect(dlg, &OptionsDialog::appearanceChanged, [this]() {
13571357
updateWidth();
13581358
});
13591359
GUIUtil::ShowModalDialogAndDeleteOnClose(dlg);

src/qt/optionsdialog.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ OptionsDialog::OptionsDialog(QWidget *parent, bool enableWallet) :
194194
appearanceLayout->addWidget(appearance);
195195
ui->widgetAppearance->setLayout(appearanceLayout);
196196

197-
connect(appearance, &AppearanceWidget::appearanceChanged, [=](){
197+
connect(appearance, &AppearanceWidget::appearanceChanged, [this](){
198198
updateWidth();
199199
Q_EMIT appearanceChanged();
200200
});
@@ -277,13 +277,13 @@ void OptionsDialog::setModel(OptionsModel *_model)
277277
connect(ui->lang, qOverload<>(&QValueComboBox::valueChanged), [this]{ showRestartWarning(); });
278278
connect(ui->thirdPartyTxUrls, &QLineEdit::textChanged, [this]{ showRestartWarning(); });
279279

280-
connect(ui->coinJoinEnabled, &QCheckBox::clicked, [=](bool fChecked) {
280+
connect(ui->coinJoinEnabled, &QCheckBox::clicked, [this](bool fChecked) {
281281
#ifdef ENABLE_WALLET
282282
model->node().coinJoinOptions().setEnabled(fChecked);
283283
#endif
284284
updateCoinJoinVisibility();
285-
if (_model != nullptr) {
286-
_model->emitCoinJoinEnabledChanged();
285+
if (this->model != nullptr) {
286+
this->model->emitCoinJoinEnabledChanged();
287287
}
288288
updateWidth();
289289
});
@@ -293,7 +293,7 @@ void OptionsDialog::setModel(OptionsModel *_model)
293293
// Store the current CoinJoin enabled state to recover it if it gets changed but the dialog gets not accepted but declined.
294294
#ifdef ENABLE_WALLET
295295
fCoinJoinEnabledPrev = model->node().coinJoinOptions().isEnabled();
296-
connect(this, &OptionsDialog::rejected, [=]() {
296+
connect(this, &OptionsDialog::rejected, [this]() {
297297
if (fCoinJoinEnabledPrev != model->node().coinJoinOptions().isEnabled()) {
298298
ui->coinJoinEnabled->click();
299299
}

src/qt/overviewpage.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ void OverviewPage::setWalletModel(WalletModel *model)
328328
connect(model->getOptionsModel(), &OptionsModel::coinJoinRoundsChanged, this, &OverviewPage::updateCoinJoinProgress);
329329
connect(model->getOptionsModel(), &OptionsModel::coinJoinAmountChanged, this, &OverviewPage::updateCoinJoinProgress);
330330
connect(model->getOptionsModel(), &OptionsModel::AdvancedCJUIChanged, this, &OverviewPage::updateAdvancedCJUI);
331-
connect(model->getOptionsModel(), &OptionsModel::coinJoinEnabledChanged, [=]() {
331+
connect(model->getOptionsModel(), &OptionsModel::coinJoinEnabledChanged, [this]() {
332332
coinJoinStatus(true);
333333
});
334334

0 commit comments

Comments
 (0)