Prevent `-Weffc++` and `-W-ctor-dtor-privacy` warnings from leaking out
I maintainer di solito rispondono entro 2 giorni
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 35/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Ferma
- Stack tecnologico
- cmake, cpp
- Ambito
- build-system, testing-qa
Direzione di ricerca
Inizia riproducendo la build di GCC 13.3.0 con gli header Catch2 elencati, quindi esamina come i target di inclusione e gli header di Catch2 vengono esposti tramite CMake FetchContent. Il lavoro è completato quando gli avvisi -Weffc++ e -W-ctor-dtor-privacy non trapelano più da Catch2, mentre la diagnostica del consumer rimane efficace.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Description
I updated Catch2 used in my project from some old Catch2v2 version to v3. When including Catch2 in my project tests through the CMake fetcher as a dependency, compiling the project with Clang (clang 17.0.6) does not issue any warnings, but compiling with GCC (g++ 13.3.0) issues a number of -Weffc++ and -W-ctod-dtor-privacy warnings.
I presume the code in Catch2 is supposed to behave as it does. Therefore, suppressing these warnings on a per-header file level should be the correct answer (or anything similar to this) to removing these warnings, while still allowing the users of Catch2 to include specific header files with the warnings set up for their tests source code.
Steps to reproduce
CMake snippet:
if (BUILD_TESTING)
# Catch2 library for writing tests
FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.7.1
)
FetchContent_MakeAvailable(Catch2)
list(APPEND CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/contrib)
include(Catch)
endif()
target_link_libraries(tests PRIVATE <project files> Catch2::Catch2WithMain)
Tests source C++ file:
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
// Tests.
Additional context
Generated warnings:
- (binary)
user-defined <some class>::operator ... always evaluates both arguments, all member functions in class <some class> are private,<some class> has pointer data members ... but does not declare ...,- ...
Log of the build process: warnings.txt.
Suggested alternative
There are a number of options to suppress these warnings.
Manually, each user can disable the warnings for each test source file, for example by wrapping the includes of Catch2 headers in pragmas:
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#include <catch2/catch_test_macros.hpp>
#include <catch2/matchers/catch_matchers_string.hpp>
#pragma GCC diagnostic pop
I also managed to suppress the warnings on a per-project basis by setting the Catch2 library as a system library in CMake: (include inside the above-mentioned CMake code after the line include(Catch)):
get_target_property(catch2_includes Catch2 INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(Catch2 SYSTEM INTERFACE ${catch2_includes})
Nevertheless, I think that the preferred approach would be to suppress these warnings on the Catch2 side once and for all (whichever approach is chosen), as opposed to forcing each user of Catch2 to suppress the warnings manually in their projects.
Related issues
https://github.com/catchorg/Catch2/issues/208
https://github.com/catchorg/Catch2/issues/407
- Lingua principale
- C++
- Stelle
- 21.6k
- Fork
- 3.4k
- Merge medio
- 3g 12h
- PR unite (30g)
- 5
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di catchorg/Catch2
-
catch_discover_tests fails for Windows test executables run under Wine since v3.15.2Forse già presa Una pull request collegata a questa issue è aperta o già unita. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 79/100
I maintainer di solito rispondono entro 2 giorni
-
catch_discover_tests passes all EXTRA_ARGS as one argumentForse già presa @CyberKun l’ha presa 11 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
catchorg/Catch2#3239 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Not seeing some error messages from fakeit in jetbrains riderForse già presa @Amanpal9 l’ha presa 21 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
catchorg/Catch2#3228 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
catch_discover_tests fails for Emscripten/WASM tests since v3.16.0Forse già presa @nafiurahman00 l’ha presa 8 giorni fa. ApertaExtras
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
catchorg/Catch2#3241 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 35/100
I maintainer di solito rispondono entro 2 giorni
Tutte le issue di catchorg/Catch2
Issue simili
-
Build fails on macOS 27: dyld refuses stripped Rust proc-macros (mis-aligned LINKEDIT string pool)Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
cloudflare/workerd#8963 ·
I maintainer di solito rispondono entro 1 giorno
-
Android Bug Core Drape
Difficoltà 2/5 1-3 ore Idoneità per principianti 77/100
organicmaps/organicmaps#14449 ·
I maintainer di solito rispondono entro 1 giorno
-
comp-codecs
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
ClickHouse/ClickHouse#135159 ·
I maintainer di solito rispondono entro 1 giorno
-
difficulty:easy func:python os:windows prio:high type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
NatronGitHub/Natron#2029 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
ardazishvili/Sota#114 ·
I maintainer di solito rispondono entro 1 giorno