DOC: Add compiler-cautions.md — compiler-specific pitfalls from 10 years of COMP: commits#5999
Merged
hjmjohnson merged 3 commits intoInsightSoftwareConsortium:mainfrom Apr 2, 2026
Conversation
baf6655 to
e1085de
Compare
dzenanz
reviewed
Apr 1, 2026
Member
dzenanz
left a comment
There was a problem hiding this comment.
Generally looks good. I did not read the first commit thoroughly. Someone else should review this.
N-Dekker
reviewed
Apr 1, 2026
e1085de to
d0e0fbf
Compare
issakomi
reviewed
Apr 1, 2026
4 tasks
- Disable llvmlibc-* (LLVM stdlib internals, never applicable to ITK) - Disable modernize-use-trailing-return-type (ITK uses leading return types) - Disable readability-redundant-member-init (ITK prefers explicit base-class init) - Expand readability-identifier-length.IgnoredParameterNames to cover single-letter index/coordinate params (i,j,k,n,x,y,z,r,g,b,a,v) commonly used in ITK math-heavy code Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Distilled from review of 1,296+ COMP: commits (2019-2026), GitHub PR review comments, and CDash failure analysis. Covers: - Smart pointer / forward-declared type hazards (GCC 7-9.1 brace-init bug, destructor-in-header UB with unique_ptr<Incomplete>) - Template deduction pitfalls (missing typename, non-type param type mismatch, constexpr static ODR-use in lambdas) - constexpr edge cases (MSVC x86 if constexpr, function pointer arrays) - Undefined behavior patterns (bit shift overflow, implicit truncation, empty-vector data(), uninitialized loop vars) - Platform specifics (char signedness on ARM, missing <cstdint> on GCC 13+, reserved identifiers on AppleClang) - GCC warnings (-Wmaybe-uninitialized false positives on ARM64, -Wdeprecated-copy Rule of Zero violations) - MSVC C4805 bool/int mixing, constexpr arrays - Clang suppression macros for third-party headers - ITK deprecated API replacements (ITK_LEGACY_REMOVE=ON breaks) - Shared library symbol visibility (ITK_TEMPLATE_EXPORT) - Python binding removals (np.bool, PySequence_Fast_GET_ITEM) - 13-item refactoring checklist Add routing entry to AGENTS.md table. Document that refactoring should not introduce new clang-tidy diagnostics, and enumerate check families that conflict with ITK coding standards (llvmlibc-*, readability-identifier-length, google-*, etc.). AI agents must consult compiler-cautions.md, compile the changed module, and run relevant tests before committing C++ code. Update AGENTS.md routing row for commit tasks to surface these docs.
4de9274 to
08a59b5
Compare
Contributor
|
| Filename | Overview |
|---|---|
| Documentation/AI/compiler-cautions.md | New 541-line reference document covering 12 compiler-pitfall categories; two issues: sections 12 and 13 appear out of order in the file body, and the PySequence_GetItem "GOOD" example omits the mandatory null check. |
| AGENTS.md | Adds a routing row for compiler-cautions.md and expands the "Creating a git commit" row to bundle compiler, build, and test references; both changes are consistent with the new document. |
| .clang-tidy | Disables three check families documented as ITK-incompatible (llvmlibc-*, modernize-use-trailing-return-type, readability-redundant-member-init) and broadens IgnoredParameterNames to include common scientific-computing single-char identifiers; fully aligned with compiler-cautions.md §13b. |
| Documentation/AI/git-commits.md | Appends a three-step pre-commit checklist (review cautions, compile, test) with correct relative links to compiler-cautions.md, building.md, and testing.md; clean addition with no issues. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[AI agent / human contributor\nbegins C++ work] --> B{Task type?}
B -- Refactoring / cross-platform fix --> C[Load compiler-cautions.md\nAGENTS.md routing]
B -- Writing new code --> D[Load conventions.md\nstyle.md]
C --> E[Check Quick-Ref Checklist §12]
D --> E
E --> F[Write / modify C++ code]
F --> G[Pre-commit checklist\ngit-commits.md §Pre-Commit]
G --> G1[1. Re-read compiler-cautions.md]
G --> G2[2. Build affected module\nbuilding.md]
G --> G3[3. Run targeted tests\nctest -R pattern]
G1 & G2 & G3 --> H[git commit]
H --> I[Open PR → pull-requests.md]
Reviews (1): Last reviewed commit: "DOC: Add compiler-cautions.md with pitfa..." | Re-trigger Greptile
- §11b: add mandatory null check before Py_DECREF after PySequence_GetItem — omitting it is UB if the call returns NULL - Renumber §12/§13: clang-tidy section was numbered 13 but appeared before §12 (Checklist) in the file; renumber to match physical order
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.
Summary
Adds
Documentation/AI/compiler-cautions.md, a reference document for AI agentsand human contributors cataloguing compiler-specific pitfalls and refactoring
hazards distilled from:
COMP:commits (2019–2026)Adds a routing entry to the
AGENTS.mdcontext table so agents load thisdocument when working on refactoring or cross-platform fixes.
Document Coverage (12 sections)
{}brace-init bug (PR #3877); destructor-in-header UB withunique_ptr<Incomplete>(PR #5997)typename(AppleClang 12+); non-type param type mismatchint/unsigned int;constexpr staticODR-use in lambdas (GCC 7)constexprpitfallsif constexprwith runtime sub-expressions;constexprarray of function pointersdata()on emptystd::vector; uninitialized loop varscharsignedness on ARM Linux; missing<cstdint>on GCC 13+; reserved identifiers on AppleClang-Wmaybe-uninitializedfalse positives on ARM64 (GCC 11+);-Wdeprecated-copyRule of Zerobool |= int;constexprfunction pointer arrays-Wzero-as-null-pointer-constantin third-party headers;-Wduplicate-enum;-Wunused-lambda-captureitkTypeMacro,ITK_DISALLOW_COPY_AND_ASSIGN,itkStaticConstMacro— hard errors withITK_LEGACY_REMOVE=ONITK_TEMPLATE_EXPORTon explicit instantiationsnp.bool(NumPy 1.24+);PySequence_Fast_GET_ITEM(Python 3.14)AI Assistance Disclosure
Research and document structure generated with Claude Code / claude-sonnet-4-6.
All pitfall entries are grounded in specific ITK commits, PR numbers, and CDash
build configurations cited in the document. Human author reviewed entries for
accuracy before committing.
Test plan
compiler-cautions.mdrenders correctly on GitHub🤖 Generated with Claude Code (claude-sonnet-4-6)