Skip to content

COMP: Fix deprecated-copy-with-dtor via rule of zero + rule of five (cf. #6538)#6670

Merged
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:comp-rule-of-zero-dtor-6538
Jul 21, 2026
Merged

COMP: Fix deprecated-copy-with-dtor via rule of zero + rule of five (cf. #6538)#6670
hjmjohnson merged 1 commit into
InsightSoftwareConsortium:mainfrom
hjmjohnson:comp-rule-of-zero-dtor-6538

Conversation

@hjmjohnson

@hjmjohnson hjmjohnson commented Jul 21, 2026

Copy link
Copy Markdown
Member

Silences all -Wdeprecated-copy-with-dtor warnings on five Core/Common classes, choosing the fix per class kind: rule of zero for the value/leaf types, rule of five for the polymorphic bases. Compare with #6538 (rule of five for all five).

Class Kind Fix here
DefaultVectorPixelAccessor value remove ~=default (rule of zero)
MinPriorityQueueElementWrapper leaf (inherits virtual dtor) remove ~=default (rule of zero)
MaxPriorityQueueElementWrapper leaf remove ~=default (rule of zero)
ElementWrapperInterface polymorphic base keep virtual ~=default + ITK_DEFAULT_COPY_AND_MOVE
ElementWrapperPointerInterface polymorphic base keep virtual ~=default + ITK_DEFAULT_COPY_AND_MOVE
Why the two treatments

ElementWrapperInterface/ElementWrapperPointerInterface are documented public extension points ("you can use this wrapper … it follows the ElementWrapperInterface and thus can be used in the queue") with virtual members. Removing their virtual destructor would break delete through ElementWrapperInterface* for downstream custom wrappers (C++ Core Guideline C.35) — so those keep the virtual destructor and get ITK_DEFAULT_COPY_AND_MOVE (same as #6538). The three value/leaf classes are never a polymorphic-delete base, so rule of zero is safe and lighter.

This split was prompted by a Greptile P1 on an earlier revision that removed the interface virtual destructors; see the resolved thread.

Warnings fixed (CDash build 11383687, Mac14.x-AppleClang-dbg)

Fixes all 33 ITK-proper -Wdeprecated-copy-with-dtor warnings (28 DefaultVectorPixelAccessor, 4 Min, 2 ElementWrapperInterface, 1 Max). The only 2 remaining of this type are ThirdParty/GDCM/gdcmFile.h (vendored upstream), which #6538 also excludes.

Local validation
  • Instantiation harness over all five templates (forced full instantiation) + queue push/pop + copy/move → compiles and runs clean.
  • Polymorphic-destruction check: delete of a custom wrapper through ElementWrapperInterface* runs the derived destructor (count = 1).
  • pre-commit run --all-files clean.

Relative to #6538: identical on the two interfaces (virtual dtor + ITK_DEFAULT_COPY_AND_MOVE), differs only on the three value/leaf classes (rule of zero vs the macro). The two PRs touch the same lines, so only one should merge. Follows #6664 (rule of zero for LogicOpBase) and #5849 (rule of zero for NthElementPixelAccessor).

@hjmjohnson
hjmjohnson marked this pull request as ready for review July 21, 2026 14:54
@github-actions github-actions Bot added type:Compiler Compiler support or related warnings area:Core Issues affecting the Core module labels Jul 21, 2026
@hjmjohnson

Copy link
Copy Markdown
Member Author

Related work — this continues an established rule-of-zero campaign

This PR isn't a one-off: it's the next step in a consistent, already-merged effort to clear the -Wdeprecated-copy-with-*-dtor warnings by removing redundant special members (rule of zero) rather than declaring them. That context is the strongest argument for preferring this over the macro approach in #6538.

Timeline
PR Merged What it did
#6430 2026-06-11 Removed -Wno-deprecated from ITK's warning flags — the root cause: it un-suppressed these -Wdeprecated-copy-with-dtor warnings so they now show on CDash.
#5849 2026-03-03 Rule of zero for NthElementPixelAccessor — a pixel accessor, directly analogous to DefaultVectorPixelAccessor in this PR.
#6592 2026-07-14 Rule of zero for functors with user-declared destructors (~MaskInput, ~SimilarPixelsFunctor, …).
#6664 2026-07-20 Rule of zero for LogicOpBase.
this PR Rule of zero for DefaultVectorPixelAccessor + the priority-queue wrapper/interface classes (the remaining CDash offenders).

The 2024 ITK_DEFAULT_COPY_AND_MOVE series (#4652, #4639, #4627, #4626, #4725) established the rule-of-five macro that #6538 uses. The 2026 campaign above has consistently chosen the rule-of-zero direction instead, which is what this PR follows.

Net: #6538 and this PR fix the same 33 warnings; merging this one keeps the codebase aligned with the #5849 / #6592 / #6664 precedent (less code, no macro). Only one of the two is needed.

@greptile-apps

This comment was marked as resolved.

Comment thread Modules/Core/Common/include/itkPriorityQueueContainer.h
Remove the user-declared defaulted destructors from the value/leaf
classes (DefaultVectorPixelAccessor, Min/MaxPriorityQueueElementWrapper)
so the compiler synthesizes their special members. Keep the virtual
destructor on the polymorphic extension-point bases
(ElementWrapperInterface, ElementWrapperPointerInterface) and declare
copy/move with ITK_DEFAULT_COPY_AND_MOVE so polymorphic destruction
through the base pointer is preserved.

Silences -Wdeprecated-copy-with-dtor (Apple Clang) on all five classes.
@hjmjohnson
hjmjohnson force-pushed the comp-rule-of-zero-dtor-6538 branch from 861780c to c24ab3c Compare July 21, 2026 15:27
@hjmjohnson hjmjohnson changed the title COMP: Apply rule of zero to fix deprecated-copy-with-dtor warnings (alternative to #6538) COMP: Fix deprecated-copy-with-dtor via rule of zero + rule of five (cf. #6538) Jul 21, 2026
@hjmjohnson
hjmjohnson merged commit ec46d0c into InsightSoftwareConsortium:main Jul 21, 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 type:Compiler Compiler support or related warnings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants