Fix -Wsfinae-incomplete warnings when building with GCC 16.x#949
Fix -Wsfinae-incomplete warnings when building with GCC 16.x#949hebasto wants to merge 1 commit into
-Wsfinae-incomplete warnings when building with GCC 16.x#949Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ReviewsSee the guideline and AI policy for information on the review process. |
|
🚧 At least one of the CI tasks failed. HintsTry to run the tests locally, according to the documentation. However, a CI failure may still
Leave a comment here, if you need help tracking down a confusing failure. |
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.
According to the CMake documentation for
AUTOMOC, allmocoutput 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 includedmoc_*.cppfile pulls in the header that defines it. GCC 16.x diagnoses this pattern with the-Wsfinae-incompletewarning, which is enabled by default.Including the
mocoutput files at the end of the corresponding source files excludes them frommocs_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 @ 18c05d9 on Fedora 44 (GCC 16.1.1):