COMP: Remove default -Wno-deprecated from the ITK warning flags#6430
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
54613f7 to
9b10931
Compare
|
Addressed the P2: commit body reworded to a 5-line why-only message within the prose-budget caps (9b10931), and the PR visible summary trimmed under 250 chars. |
9b10931 to
37592a0
Compare
A user-declared copy constructor deprecates the implicitly-generated copy assignment operator (-Wdeprecated-copy under Clang -Wextra). Explicitly default the previously implied operators.
A user-declared copy constructor or copy assignment deprecates the complementary implicit member (-Wdeprecated-copy under Clang -Wextra). Explicitly default the previously implied members. Candidate for upstream GDCM submission.
37592a0 to
ed4534f
Compare
|
The vendored GDCM hunk (gdcmDataSet.h/gdcmItem.h defaulted special members) has been submitted upstream as malaterre/GDCM#220; it can be dropped here on a future GDCM UpdateFromUpstream once merged. |
Clang's -Wdeprecated (no longer suppressed) flags implicit 'this' capture via [=], mixed-enum arithmetic, and std::is_pod_v in C++20 builds. Capture 'this' explicitly, cast enumerators to int, and use is_standard_layout_v && is_trivial_v.
On Clang, -Wno-deprecated subsumes -Wdeprecated-declarations and hides [[deprecated]]/ITK_DEPRECATED API warnings; on GCC the two are independent, so deprecation visibility differed by compiler. Removing the flag surfaces these warnings uniformly. ITK_CXX_WARNING_FLAGS remains available to override the warning set.
ed4534f to
cda73c4
Compare
|
ITK.Linux flagged 15 real warnings unmasked by this change in the C++20 Debug build (implicit |
|
@dzenanz 4 small follow on commits needed to remove warnings. I have asked for re-approval due to the additional changes. |
Remove the default
-Wno-deprecatedso[[deprecated]]API warnings surface uniformly: on Clang it subsumes-Wdeprecated-declarations, hiding warnings GCC still emits. The implicit-copy members it masked are fixed with= default;ITK_CXX_WARNING_FLAGSremains as an override.History — why this flag exists and why it's now stale
a33ca7ac0d7, Bill Lorensen) — "ENH: suppress deprecated header warnings for gcc compilers that support it." Added inside anIF(CMAKE_COMPILER_IS_GNUCXX)guard to silence GCC's warnings about deprecated C++ standard headers of that era (<strstream>,<ext/hash_map>, the<backward/*>SGI STL headers).8a135bcb128) — "ENH: Detect/use recommended compiler flags." ConsolidatedITKPlatformSpecificChecks.cmakeintoITKSetStandardCompilerFlags.cmake, carrying-Wno-deprecatedinto the cross-compilercxx_flagslist. From this point it applied to all C++ compilers, not just GCC.The deprecated headers it targeted are long gone. And
[[deprecated]]as a language attribute did not exist until C++14 (~2014) — five years after the flag was introduced — so it was never meant to mask attribute-based deprecations.Why it should no longer be a default
-Wno-deprecatedalso disables-Wdeprecated-declarations, so[[deprecated]]API-usage warnings are hidden. On GCC the two are independent, so GCC still warns. The same build flag thus produces different deprecation visibility per compiler — a surprising, hard-to-debug default.[[deprecated]]/ITK_DEPRECATEDto steer users off them; this flag silently undoes that on Clang. It likewise hides vendored deprecations (e.g. the in-progressvnl_math::deprecations inModules/ThirdParty/VNL).-DITK_CXX_WARNING_FLAGS:STRING="…"(the cache override atITKSetStandardCompilerFlags.cmake), or add-Wno-deprecatedviaCMAKE_CXX_FLAGS.Expected effect: previously-masked
-Wdeprecated-declarationswarnings now appear on Clang builds (as they already do on GCC). ITK does not build with-Werrorby default, so this surfaces warnings without breaking the build.Newly-unmasked -Wdeprecated-copy warnings — fixed, not suppressed
Removing the blanket
-Wno-deprecatedalso unmasked Clang's-Wextra-driven-Wdeprecated-copylint (ARMBUILD-x86_64-rosetta failed: the dashboard gate counts any warning as fatal). All sites are fixed by explicitly defaulting the previously implied special members (no semantic change; move members stay undeclared because they were already suppressed by the user-declared copy members, and= deletewould change overload resolution):itkQuadEdgeMeshBaseIterator.h— 4 iterator classes with defaulted copy ctoroperator== defaultitkTriangleMeshToBinaryImageFilter.h—Point1Doperator== defaultgdcmDataSet.h— user-declared copy assignment= defaultgdcmItem.h— user-provided copy ctoroperator== defaultThe GDCM hunk is submitted upstream as malaterre/GDCM#220.
ITK.Linux's C++20 Debug build additionally surfaced
-Wdeprecated-family warnings, fixed the same way (bacd856):itkNiftiImageIO.cxx—[=]lambda implicitly capturesthis(deprecated in C++20)thisexplicitlyGe5xHdr.h— arithmetic between different enumeration typesstatic_cast<int>on enumeratorsitkAggregateTypesGTest.cxx—std::is_pod_v(deprecated since C++20), 6 sitesis_standard_layout_v && is_trivial_vCommits are ordered fixes-first so every commit builds warning-clean. Validated locally: clang reproducer shows the
itkQuadEdgeMeshBaseIterator.h:282warning pre-fix and none post-fix;ITKQuadEdgeMeshTestDriver,ITKMeshTestDriver,gdcmDSED,gdcmMSFFbuild clean; touched-class tests 6/6 pass.