COMP: Fix Mac nightly compile errors (VTI test + ImageAlgorithm CTAD)#6219
Conversation
|
@greptileai review this draft before I make it official |
This comment was marked as resolved.
This comment was marked as resolved.
b808bf5 to
74f423e
Compare
itkVTIImageIOReadWriteTest at line 92 took the bare-name 'GetImageIO()' overload, which the 'itkGetModifiableObjectMacro(ImageIO, ImageIOBase)' declaration only emits when 'ITK_FUTURE_LEGACY_REMOVE' is OFF (the historical default). When the future-strict mode is ON, the macro emits only 'GetModifiableImageIO()' and 'const ImageIOBase * GetImageIO() const'; the bare 'GetImageIO()' returns a const pointer and the test fails to compile with four cascading errors: error: no matching member function for call to 'SetFileName' error: 'this' argument to 'ReadImageInformation' has type 'const ImageIOBase', but function is not marked const error: no matching function for call to 'internalMain' (line 104) error: no matching function for call to 'internalMain' (line 106) The PR-time CI green-lit the test because no per-PR builder configures 'ITK_FUTURE_LEGACY_REMOVE=ON'; the failure surfaced only after the nightly Mac AppleClang dbg-Universal pipelines (Rogue Research 17/19/ 20/24/25/26/27) ran, where the strict-future flag is set. Switching to 'GetModifiableImageIO()' compiles cleanly under both legacy and strict-future macro expansions. Observed on the 2026-05-05 nightly across every Mac dbg-Universal / ASanUBSan / TSan / arm64 build site (5+ buildgroups, 4 errors per site). No behavioral change for runtime users — the call site needed a non-const ImageIOBase pointer all along.
itkImageAlgorithm::DispatchedCopy(...) at lines 56-57 declares the
input/output region iterators via class-template-argument-deduction
('ImageRegionConstIterator it(inImage, inRegion);'). AppleClang in
the dbg-Universal builds with strict CTAD checking refuses the
deduction with 'no viable constructor or deduction guide for deduction
of template arguments of "ImageRegionConstIterator"' / "ImageRegionIterator".
The neighboring 'ImageScanline*Iterator' declarations a few lines above
ship their own deduction guides and are accepted on the same compiler;
the Region iterators do not. Spelling out the template arguments
explicitly compiles cleanly on every supported toolchain and removes
the dependence on a deduction guide that AppleClang's CTAD does not
synthesize.
Observed on the 2026-05-05 nightly:
- MacOS-Rel-Python (12 errors)
- MacOS-Rel-MorphologicalContourInterpolation (12 errors)
Both buildgroups configure with stricter CTAD than the per-PR Linux
and Windows builders, which is why the issue surfaced only at nightly
time. No behavioral or runtime change.
Locks in correct iterator type deduction for itk::ImageAlgorithm::Copy when the source or destination is a partially-specialized Image-like template (RLEImage). Discovered while ingesting the MorphologicalContourInterpolation remote module: the prior CTAD form in itkImageAlgorithm.hxx silently selected the primary-template iterator for RLEImage on gcc (runtime SIGABRT) while AppleClang 17 refused to compile. The companion fix in this branch spells the template arguments explicitly; this regression test exercises both copy directions so a future CTAD re-introduction is caught at test time on every supported toolchain. The same trap can affect any future user of itk::ImageAlgorithm::Copy with a partially-specialized Image-like template.
74f423e to
020f37d
Compare
|
I could not write an inline comment the normal way. In the first commit, I have a question. I feel like |
|
@dzenanz Good question. I grep'd every The VTI test is the only call site that needs a non-const
The VTI test (line 92) is unique because it (a) uses So Separately, the recurring "test passes per-PR, fails on nightly because nightly enables strict modes" pattern argues for a |
|
Thanks for the investigation. Good to merge when CI comes back green. |
Fix two compile-error clusters first observed on the 2026-05-05 nightly dashboard: a const-correctness slip in
itkVTIImageIOReadWriteTest.cxxthat surfaces only whenITK_FUTURE_LEGACY_REMOVE=ON(Mac dbg-Universal builds), and a CTAD deduction failure initkImageAlgorithm.hxxthat surfaces only on AppleClang's stricter deduction (Mac Python + Mac remote-modules builds). Both fixes are one-/two-line changes with no behavioral effect at runtime.A third commit adds a GoogleTest regression covering
ImageAlgorithm::CopywithRLEImagesource/destination — the CTAD bug was discovered while ingesting ITKMorphologicalContourInterpolation (PR #6209), where it caused SIGABRT on gcc-11 and a compile error on AppleClang 17.Failing CDash buildgroups and counts
Source: https://open.cdash.org/index.php?project=Insight&date=2026-05-05
Mac14.x-AppleClang-dbg-UniversalMac13.x-AppleClang-dbg-UniversalMac10.15-AppleClang-dbgMac26.x-ClangMain-dbg-arm64Mac26.x-AppleClang-dbg-TSanMac15.x-AppleClang-dbg-ASanUBSanMac11.x-AppleClang-dbgMac12.x-AppleClang-dbg-arm64MacOS-Rel-PythonMacOS-Rel-MorphologicalContourInterpolationTotal: 8 sites × 4 errors (#1) + 2 sites × 12 errors (#2) = 56 compile errors cleared.
Fix #1 — `itkVTIImageIOReadWriteTest.cxx` const-correctness under `ITK_FUTURE_LEGACY_REMOVE=ON`
Commit:
COMP: Use GetModifiableImageIO() in VTI test for ITK_FUTURE_LEGACY_REMOVE buildsFailing line (introduced by PR #6032 merged 2026-05-01):
Diagnostic (representative of all 4 errors):
Root cause:
itkGetModifiableObjectMacro(ImageIO, ImageIOBase)expands differently based onITK_FUTURE_LEGACY_REMOVE:GetModifiableImageIO()(non-const),GetImageIO() const(returningconst ImageIOBase *), and a legacy-fallback non-constGetImageIO(). The barereader->GetImageIO()resolves to the non-const fallback; the test compiles.GetModifiableImageIO()andGetImageIO() const; the barereader->GetImageIO()returnsconst ImageIOBase *.autodeduces const, every subsequent call needing a non-const path errors out.The PR-time CI green-lit the test because no per-PR builder configures
ITK_FUTURE_LEGACY_REMOVE=ON. The Rogue Research Mac dbg-Universal nightly pipelines do, exposing the regression.Fix: change the bare-name call to the modifiable getter — works under both legacy and strict-future expansions.
Fix #2 — `itkImageAlgorithm.hxx` CTAD deduction on AppleClang
Commit:
COMP: Spell template args on ImageRegion iterators in DispatchedCopyFailing lines (in
ImageAlgorithm::DispatchedCopy):Diagnostic:
Root cause: class-template-argument-deduction (CTAD) used without an explicit deduction guide.
ImageScanlineConstIterator/ImageScanlineIterator(a few lines above, lines 39-40) ship deduction guides and compile cleanly;ImageRegionConstIterator/ImageRegionIteratordo not. AppleClang's CTAD on the failing builds is stricter than gcc/MSVC, exposing the asymmetry.The two surfaces affected (
MacOS-Rel-PythonZukicM1.kitware,MacOS-Rel-MorphologicalContourInterpolationZukicM1.kitware) trigger the same 12-error count because every consumer ofImageAlgorithm.hxxfrom those buildgroups instantiates the path throughDispatchedCopy.Fix: spell the template argument explicitly. Compiles on every toolchain, removes the deduction-guide dependency. Could alternatively add a deduction guide to
itkImageRegionConstIterator.h/itkImageRegionIterator.hfor parity with the Scanline iterators — that's a separate cleanup PR.Fix #3 — RLEImage GTest regression for ImageAlgorithm::Copy iterator deduction
Commit:
ENH: Add RLEImage GTest covering ImageAlgorithm::Copy iterator deductionThe CTAD bug (fix #2) was first identified while ingesting
ITKMorphologicalContourInterpolation(PR #6209).RLEImageis a partially-specializedImage-like template whose iterator types lack visible deduction guides at theitkImageAlgorithm.hxxparse site. On AppleClang 17 this produced 12 compile errors; on gcc-11 it silently selected the primary-template iterator and caused SIGABRT at runtime.Two
GoogleTestcases added toModules/Filtering/RLEImage/test/:RLEImageAlgorithmCopy.FromRLEToImage— copies a filledRLEImageinto a standardImage; verifies all pixels viaImageRegionConstIterator.RLEImageAlgorithmCopy.FromImageToRLE— copies a filled standardImageinto anRLEImage; verifies all pixels viaImageRegionConstIterator<RLEType>.Both were verified locally with Apple-clang 17 in
~/src/ITK-mci/buildbefore this push.What this PR does not address
Other 2026-05-05 dashboard symptoms have separate root causes and are out of scope here:
itkSquareImageFilterTest,itkRoundImageFilterTest, etc.) — CDash dashboard drift after recent GoogleTest-driver consolidation (PRs ENH: Convert four no-arg Common tests to GoogleTest #6132, ENH: Convert 8 IO/ImageBase tests to GoogleTest #6177, ENH: Convert 8 ImageIntensity tests to GoogleTest #6197, ENH: Convert 10 Numerics/Statistics tests to GoogleTest #6200). The tests still run; the historical CTest names disappeared. Needs CDash expected-test refresh, not a code change.Windows11-VS22x64-RelWithDebInfo-Favorite-Remotes56 real test failures — likely MSVC numerical drift in registration tests post recent remote-module ingests (ENH: Ingest ITKLabelErodeDilate into Modules/Filtering #6171, ENH: Ingest ITKCuberille into Modules/Filtering #6205). Needs nightly bisect.Windows11-VS2022-Static-DebugTBB3 failures andWindows11-VS2026-Shared-ReleaseTBB1 failure — likely TBB-specific.itk-valgrind/itk-coveragesporadic — long-running, treat as flake until reproducible.Each of those merits a separate fix PR if persistent.
Suggested follow-up
The recurring pattern — test passes per-PR, fails on nightly because nightly enables strict modes — argues for adding a
Pixi-Cxx-Strictor equivalent GHA job that builds with-DITK_FUTURE_LEGACY_REMOVE=ON. That would have caught fix #1 at PR time and saved a 24-hour nightly cycle. Comparable rationale for an AppleClang-CTAD job for fix #2, though the case for that one is weaker (Apple-only, low frequency).