Fix `-Wsfinae-incomplete` warnings when building with GCC 16.x #949

pull hebasto wants to merge 1 commits into bitcoin-core:master from hebasto:260719-sfinae changing 5 files +17 −3
  1. hebasto commented at 4:40 PM on July 19, 2026: member

    According to the CMake documentation for AUTOMOC, all moc output files that are not included in a source file are aggregated into the CMake-generated <AUTOGEN_BUILD_DIR>/mocs_compilation.cpp, which is added to the target's sources.

    Within that single translation unit, moc-generated code checks the completeness of a signal or slot parameter type while it is still only forward-declared, and the type is completed later, when a subsequently included moc_*.cpp file pulls in the header that defines it. GCC 16.x diagnoses this pattern with the -Wsfinae-incomplete warning, which is enabled by default.

    Including the moc output files at the end of the corresponding source files excludes them from mocs_compilation.cpp, so each one is compiled in a translation unit where the relevant types are complete.

    FWIW, Qt itself uses the same approach throughout its own codebase. Also see https://www.youtube.com/watch?v=Cx_m-qVnEjo.


    Steps to reproduce on the master branch @ 18c05d93016b28a9afd4c716dfe00b6e0accb30b on Fedora 44 (GCC 16.1.1):

    $ cmake --preset dev-mode
    $ cmake --build build_dev_mode -t bitcoind
    $ cmake --build build_dev_mode -t bitcoin-qt
    [166/172] Building CXX object src/qt/CMakeFiles/bitcoinqt.dir/bitcoinqt_autogen/mocs_compilation.cpp.o
    In file included from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_bitcoingui.cpp:9,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:9:
    /home/hebasto/dev/bitcoin-gui/src/qt/bitcoingui.h:67:7: warning: defining ‘BitcoinGUI’, which previously failed to be complete in a SFINAE context [-Wsfinae-incomplete=]
       67 | class BitcoinGUI : public QMainWindow
          |       ^~~~~~~~~~
    In file included from /usr/include/qt6/QtCore/qobject.h:19,
                     from /usr/include/qt6/QtWidgets/qwidget.h:10,
                     from /usr/include/qt6/QtWidgets/qdialog.h:9,
                     from /usr/include/qt6/QtWidgets/QDialog:1,
                     from /home/hebasto/dev/bitcoin-gui/src/qt/addressbookpage.h:8,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_addressbookpage.cpp:9,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:2:
    /usr/include/qt6/QtCore/qmetatype.h:344:64: note: here.  Use ‘-Wsfinae-incomplete=2’ for a diagnostic at that point
      344 |         static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
          |                                                                ^~~~~~~~~
    In file included from /home/hebasto/dev/bitcoin-gui/src/qt/paymentserver.h:35,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_paymentserver.cpp:9,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:27:
    /home/hebasto/dev/bitcoin-gui/src/qt/sendcoinsrecipient.h:15:7: warning: defining ‘SendCoinsRecipient’, which previously failed to be complete in a SFINAE context [-Wsfinae-incomplete=]
       15 | class SendCoinsRecipient
          |       ^~~~~~~~~~~~~~~~~~
    /usr/include/qt6/QtCore/qmetatype.h:344:64: note: here.  Use ‘-Wsfinae-incomplete=2’ for a diagnostic at that point
      344 |         static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
          |                                                                ^~~~~~~~~
    In file included from /home/hebasto/dev/bitcoin-gui/src/qt/psbtoperationsdialog.h:13,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_psbtoperationsdialog.cpp:9,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:30:
    /home/hebasto/dev/bitcoin-gui/src/qt/walletmodel.h:48:7: warning: defining ‘WalletModel’, which previously failed to be complete in a SFINAE context [-Wsfinae-incomplete=]
       48 | class WalletModel : public QObject
          |       ^~~~~~~~~~~
    /usr/include/qt6/QtCore/qmetatype.h:344:64: note: here.  Use ‘-Wsfinae-incomplete=2’ for a diagnostic at that point
      344 |         static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
          |                                                                ^~~~~~~~~
    In file included from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_qvalidatedlineedit.cpp:9,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:32:
    /home/hebasto/dev/bitcoin-gui/src/qt/qvalidatedlineedit.h:13:7: warning: defining ‘QValidatedLineEdit’, which previously failed to be complete in a SFINAE context [-Wsfinae-incomplete=]
       13 | class QValidatedLineEdit : public QLineEdit
          |       ^~~~~~~~~~~~~~~~~~
    /usr/include/qt6/QtCore/qmetatype.h:344:64: note: here.  Use ‘-Wsfinae-incomplete=2’ for a diagnostic at that point
      344 |         static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
          |                                                                ^~~~~~~~~
    In file included from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_rpcconsole.cpp:9,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:37:
    /home/hebasto/dev/bitcoin-gui/src/qt/rpcconsole.h:43:7: warning: defining ‘RPCConsole’, which previously failed to be complete in a SFINAE context [-Wsfinae-incomplete=]
       43 | class RPCConsole: public QWidget
          |       ^~~~~~~~~~
    /usr/include/qt6/QtCore/qmetatype.h:344:64: note: here.  Use ‘-Wsfinae-incomplete=2’ for a diagnostic at that point
      344 |         static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
          |                                                                ^~~~~~~~~
    In file included from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/EWIEGA46WW/moc_sendcoinsentry.cpp:9,
                     from /home/hebasto/dev/bitcoin-gui/build_dev_mode/src/qt/bitcoinqt_autogen/mocs_compilation.cpp:39:
    /home/hebasto/dev/bitcoin-gui/src/qt/sendcoinsentry.h:26:7: warning: defining ‘SendCoinsEntry’, which previously failed to be complete in a SFINAE context [-Wsfinae-incomplete=]
       26 | class SendCoinsEntry : public QWidget
          |       ^~~~~~~~~~~~~~
    /usr/include/qt6/QtCore/qmetatype.h:344:64: note: here.  Use ‘-Wsfinae-incomplete=2’ for a diagnostic at that point
      344 |         static auto check(U *) -> std::integral_constant<bool, sizeof(U) != 0>;
          |                                                                ^~~~~~~~~
    [172/172] Linking CXX executable bin/bitcoin-qt
    
  2. DrahtBot commented at 4:40 PM on July 19, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline and AI policy for information on the review process.

    Type Reviewers
    ACK maflcko

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  3. DrahtBot added the label CI failed on Jul 19, 2026
  4. DrahtBot commented at 7:19 PM on July 19, 2026: contributor

    <!--85328a0da195eb286784d51f73fa0af9-->

    🚧 At least one of the CI tasks failed. <sub>Task lint: https://github.com/bitcoin-core/gui/actions/runs/29695312658/job/88214942136</sub> <sub>LLM reason (✨ experimental): CI failed because the lint-includes check detected C++ files including .cpp sources (triggering a lint “all_python_linters” failure).</sub>

    <details><summary>Hints</summary>

    Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example:

    • Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch.

    • A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test.

    • An intermittent issue.

    Leave a comment here, if you need help tracking down a confusing failure.

    </details>

  5. hebasto force-pushed on Jul 20, 2026
  6. qt: Fix `-Wsfinae-incomplete` warnings when building with GCC 16.x
    According to the CMake documentation for `AUTOMOC`, all `moc` output
    files that are not included in a source file are aggregated into the
    CMake-generated `<AUTOGEN_BUILD_DIR>/mocs_compilation.cpp`, which is
    added to the target's sources.
    
    Within that single translation unit, `moc`-generated code checks the
    completeness of a signal or slot parameter type while it is still only
    forward-declared, and the type is completed later, when a subsequently
    included `moc_*.cpp` file pulls in the header that defines it. GCC 16.x
    diagnoses this pattern with the `-Wsfinae-incomplete` warning, which is
    enabled by default.
    
    Including the `moc` output files at the end of the corresponding source
    files excludes them from `mocs_compilation.cpp`, so each one is
    compiled in a translation unit where the relevant types are complete.
    
    Additionally:
    1. Some of the `BitcoinGUI` class's private members are gated with
       `#ifdef ENABLE_WALLET` to prevent `-Wunused-private-field` warnings
       when building with `-DENABLE_WALLET=OFF`.
    2. `test/lint/lint-includes.py` is adjusted to allow new `#include`
       statements.
    51d36dfd07
  7. hebasto force-pushed on Jul 20, 2026
  8. hebasto commented at 2:33 PM on July 20, 2026: member

    Friendly ping @maflcko @l0rinc

  9. DrahtBot removed the label CI failed on Jul 20, 2026
  10. maflcko commented at 8:20 AM on July 22, 2026: contributor
    Additionally:
    1. Some of the `BitcoinGUI` class's private members are gated with
       `#ifdef ENABLE_WALLET` to prevent `-Wunused-private-field` warnings
       when building with `-DENABLE_WALLET=OFF`.
    

    How to reproduce this?

  11. hebasto commented at 8:44 AM on July 22, 2026: member
    Additionally:
    1. Some of the `BitcoinGUI` class's private members are gated with
       `#ifdef ENABLE_WALLET` to prevent `-Wunused-private-field` warnings
       when building with `-DENABLE_WALLET=OFF`.
    

    How to reproduce this?

    See the CI log for the previous state of this branch: https://github.com/bitcoin-core/gui/actions/runs/29695312658/job/88214942182.

  12. maflcko commented at 8:53 AM on July 22, 2026: contributor

    review ACK 51d36dfd076a98cd761ab312ab10792725ed7a29 🦅

    <details><summary>Show signature</summary>

    Signature:

    untrusted comment: signature from minisign secret key on empty file; verify via: minisign -Vm "${path_to_any_empty_file}" -P RWTRmVTMeKV5noAMqVlsMugDDCyyTSbA3Re5AkUrhvLVln0tSaFWglOw -x "${path_to_this_whole_four_line_signature_blob}"
    RUTRmVTMeKV5npGrKx1nqXCw5zeVHdtdYURB/KlyA/LMFgpNCs+SkW9a8N95d+U4AP1RJMi+krxU1A3Yux4bpwZNLvVBKy0wLgM=
    trusted comment: review ACK 51d36dfd076a98cd761ab312ab10792725ed7a29 🦅
    FPCJmQMr/lKRlfN1Rxure4/mbJQYCqQwEU0NY/VAGYP7hvHd8E6D5YhW1jb9y38vJ7kjMYM/YYyAV8Rc/Qf8BA==
    

    </details>

  13. hebasto merged this on Jul 22, 2026
  14. hebasto closed this on Jul 22, 2026

  15. hebasto deleted the branch on Jul 22, 2026

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-07-26 01:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me