COMP: Forward-declare itk::Indent in itkPrintHelper.h#6252
Merged
dzenanz merged 1 commit intoMay 12, 2026
Merged
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
itkPrintHelper.h is included from itkMacro.h. Common ITK headers include
itkIndent.h, which itself includes itkMacro.h, which transitively includes
itkPrintHelper.h. When itkIndent.h is the include-chain entry point, the
recursive inclusion of itkIndent.h from itkPrintHelper.h's prologue is a
header-guard no-op — class itk::Indent has NOT yet been declared at the
point itkPrintHelper.h is parsed.
Most toolchains tolerate this because the only reference to Indent in
this file is a function parameter declaration (`const Indent & indent`),
and many parsers accept forward use of an undeclared type at parse time.
Stricter configurations (Apple Clang dbg, AppleClang ASanUBSan, ClangMain,
TSan, gcc 11.4 TBB-Debug, MSVC 2022 Static-DebugTBB, Valgrind, Coverage)
reject it as:
itkPrintHelper.h:97:44: error: unknown type name 'Indent'
The fix is the same pattern already used a few lines above for NumericTraits:
add an explicit forward declaration of class Indent inside namespace itk
before the namespace itk::print_helper block. Every PrintNumericTrait()
call site already #includes itkIndent.h directly or transitively (they
need to stream `os << indent`), so the forward declaration is sufficient
for the template's parameter list to parse; the full Indent definition is
visible at every instantiation site.
Symptom across 8+ Nightly / Expected Nightly platforms (2026-05-11):
CE=1 / TF=0 / TN=~2660 — one compile error in ITKCommon blocks the
entire test grid.
81627c6 to
514ff3c
Compare
Member
Author
|
/azp run ITK.Linux |
dzenanz
approved these changes
May 12, 2026
0082640
into
InsightSoftwareConsortium:main
21 of 23 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix the common-mode compile error in
itkPrintHelper.hthat breaks 8+ Nightly / Expected Nightly platforms (Mac11/12/13/14/15/26.x, Windows VS2022 Debug, Ubuntu gcc11 TBB-Debug, Valgrind, Coverage) with the same shapeCE=1 / TF=0 / TN=~2660— one compile error inITKCommonblocks the entire test grid.Root cause
itkPrintHelper.h:97uses an unqualifiedIndentin a parameter declaration:itkPrintHelper.his included fromitkMacro.h, which is itself included fromitkIndent.h. WhenitkIndent.his the include-chain entry point (the common case for any header that streams anIndent), the recursive inclusion ofitkIndent.hfromitkPrintHelper.h's prologue is a header-guard no-op —class itk::Indenthas not yet been declared whenitkPrintHelper.h's body is parsed.Stricter toolchain configurations reject this:
Local builds against ITK's pixi-managed Clang tolerate it; the failures only surface on Apple Clang dbg / ASanUBSan / TSan / ClangMain, MSVC 2022 Static-Debug, gcc 11.4 TBB-Debug, valgrind, and coverage builds.
Fix
Mirror the existing
NumericTraitsforward declaration a few lines above, addingclass Indent;inside thenamespace itk { ... }block. EveryPrintNumericTrait()call site already#includesitkIndent.hdirectly or transitively (they need the full definition to streamos << indent), so the forward declaration is sufficient for parameter-list parsing and the template instantiates against the full definition at every call site.Affected builds on the 2026-05-11 dashboard