Skip to content

COMP: Remove default -Wno-deprecated from the ITK warning flags#6430

Merged
hjmjohnson merged 4 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:remove-wno-deprecated
Jun 11, 2026
Merged

COMP: Remove default -Wno-deprecated from the ITK warning flags#6430
hjmjohnson merged 4 commits into
InsightSoftwareConsortium:mainfrom
hjmjohnson:remove-wno-deprecated

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Jun 10, 2026

Copy link
Copy Markdown
Member

Remove the default -Wno-deprecated so [[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_FLAGS remains as an override.

History — why this flag exists and why it's now stale
  • 2009-02-12 (a33ca7ac0d7, Bill Lorensen)"ENH: suppress deprecated header warnings for gcc compilers that support it." Added inside an IF(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).
  • 2011-08-23 (8a135bcb128)"ENH: Detect/use recommended compiler flags." Consolidated ITKPlatformSpecificChecks.cmake into ITKSetStandardCompilerFlags.cmake, carrying -Wno-deprecated into the cross-compiler cxx_flags list. 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
  • Compiler-inconsistent. On Clang, -Wno-deprecated also 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.
  • It hides ITK's own intent. ITK marks APIs [[deprecated]]/ITK_DEPRECATED to steer users off them; this flag silently undoes that on Clang. It likewise hides vendored deprecations (e.g. the in-progress vnl_math:: deprecations in Modules/ThirdParty/VNL).
  • Escape hatch preserved. Anyone needing the old behavior can set -DITK_CXX_WARNING_FLAGS:STRING="…" (the cache override at ITKSetStandardCompilerFlags.cmake), or add -Wno-deprecated via CMAKE_CXX_FLAGS.

Expected effect: previously-masked -Wdeprecated-declarations warnings now appear on Clang builds (as they already do on GCC). ITK does not build with -Werror by default, so this surfaces warnings without breaking the build.

Newly-unmasked -Wdeprecated-copy warnings — fixed, not suppressed

Removing the blanket -Wno-deprecated also unmasked Clang's -Wextra-driven -Wdeprecated-copy lint (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 = delete would change overload resolution):

Site Fix
itkQuadEdgeMeshBaseIterator.h — 4 iterator classes with defaulted copy ctor operator= = default
itkTriangleMeshToBinaryImageFilter.hPoint1D operator= = default
vendored gdcmDataSet.h — user-declared copy assignment default ctor + copy ctor = default
vendored gdcmItem.h — user-provided copy ctor operator= = default

The 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):

Site Fix
itkNiftiImageIO.cxx[=] lambda implicitly captures this (deprecated in C++20) capture this explicitly
Ge5xHdr.h — arithmetic between different enumeration types static_cast<int> on enumerators
itkAggregateTypesGTest.cxxstd::is_pod_v (deprecated since C++20), 6 sites is_standard_layout_v && is_trivial_v

Commits are ordered fixes-first so every commit builds warning-clean. Validated locally: clang reproducer shows the itkQuadEdgeMeshBaseIterator.h:282 warning pre-fix and none post-fix; ITKQuadEdgeMeshTestDriver, ITKMeshTestDriver, gdcmDSED, gdcmMSFF build clean; touched-class tests 6/6 pass.

@github-actions github-actions Bot added type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots labels Jun 10, 2026
@hjmjohnson hjmjohnson marked this pull request as ready for review June 10, 2026 20:40
@hjmjohnson hjmjohnson requested a review from dzenanz June 10, 2026 20:42
@greptile-apps

This comment was marked as resolved.

@hjmjohnson hjmjohnson force-pushed the remove-wno-deprecated branch from 54613f7 to 9b10931 Compare June 10, 2026 21:09
@hjmjohnson

Copy link
Copy Markdown
Member Author

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.

@hjmjohnson hjmjohnson force-pushed the remove-wno-deprecated branch from 9b10931 to 37592a0 Compare June 10, 2026 22:24
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.
@hjmjohnson hjmjohnson force-pushed the remove-wno-deprecated branch from 37592a0 to ed4534f Compare June 10, 2026 22:34
@github-actions github-actions Bot added area:Core Issues affecting the Core module area:ThirdParty Issues affecting the ThirdParty module labels Jun 10, 2026
@hjmjohnson

Copy link
Copy Markdown
Member Author

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.
@hjmjohnson hjmjohnson force-pushed the remove-wno-deprecated branch from ed4534f to cda73c4 Compare June 11, 2026 01:29
@github-actions github-actions Bot added type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct area:IO Issues affecting the IO module labels Jun 11, 2026
@hjmjohnson

Copy link
Copy Markdown
Member Author

ITK.Linux flagged 15 real warnings unmasked by this change in the C++20 Debug build (implicit this capture via [=], mixed-enum arithmetic in Ge5xHdr.h, std::is_pod_v in tests). Fixed in bacd856, ordered before the flag-removal commit so every commit builds warning-clean; affected tests pass locally (28/28 NIFTI, 66/66 Common GTest).

@hjmjohnson hjmjohnson requested a review from dzenanz June 11, 2026 09:59
@hjmjohnson

Copy link
Copy Markdown
Member Author

@dzenanz 4 small follow on commits needed to remove warnings. I have asked for re-approval due to the additional changes.

@hjmjohnson hjmjohnson merged commit 7c368a6 into InsightSoftwareConsortium:main Jun 11, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:Core Issues affecting the Core module area:IO Issues affecting the IO module area:ThirdParty Issues affecting the ThirdParty module type:Compiler Compiler support or related warnings type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Testing Ensure that the purpose of a class is met/the results on a wide set of test cases are correct

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants