Skip to content

Case 224: Header-Only Template Default Added

Field Value
Verdict ✅ NO_CHANGE
Category No Change
Classification Rule
Platforms Linux, macOS, Windows
Flags —
Detected ChangeKinds —
Source files catalog/cases/case224_header_only_template_default_added/
Rule family header-only-template-default-added
Subject Template and generic-programming issues

Category: Template ABI | Verdict: 🟢 NO_CHANGE (castxml) / 🟠 API_BREAK (clang)

Verdict and consumer impact

v1 declares template <typename T, typename U> struct Box; with no default for U. v2 adds U = int. Source that already spells both arguments still compiles. Source that relies on the single-argument form Box<char> starts to compile and selects Box<char, int>, so the meaning of existing code can change. No symbol depends on the default, so there is no binary break.

On the default castxml lane the run reads NO_CHANGE, with the template-default assurance gap. clang records that v1 had no default and that v2 has int, and reports template_param_default_changed as API_BREAK.

Old/new diff

Old/new diff

v1.h v2.h
template <typename T, typename U> struct Box; template <typename T, typename U = int> struct Box;

abicheck command

cat > .abicheck.yml <<'EOF'
compile:
  frontend: castxml
  lang: c++
EOF
abicheck dump -H v1.h --config .abicheck.yml --depth headers -o old.json
abicheck dump -H v2.h --config .abicheck.yml --depth headers -o new.json
abicheck compare old.json new.json

Switch frontend: clang to see the clang result.

Expected abicheck finding

castxml (default): Verdict: NO_CHANGE, Assurance: partial with the gap template-parameter defaults (castxml cannot record them).

clang: Verdict: API_BREAK, template_param_default_changed.

Minimum evidence

min_evidence: L2, the public header.

Why abicheck catches it

The None-to-spelling transition is a difference in the recorded per-parameter defaults (compare/template_param_defaults.py). It is compared like any other spelling change, and it is never a clean match with an UNKNOWN side.

Runtime failure demonstration

None, as in case223.

Safe redesign

Add the default only when every existing spelling is also still valid. Otherwise put the new default on a new alias.


Source files

  • CMakeLists.txt
  • app.cpp
  • v1.cpp
  • v1.h
  • v2.cpp
  • v2.h

See also: Compatibility Catalog · All NO_CHANGE cases · Category: No Change · Rule: Header-only template default added · Subject: Template and generic-programming issues.