Case 216: Overload Added Beside an initializer_list Overload¶
| Field | Value |
|---|---|
| Verdict | 🟢 COMPATIBLE |
| Category | Addition (Compatible) |
| Classification | Rule |
| Platforms | Linux, macOS |
| Flags | — |
Detected ChangeKinds |
func_added |
| Source files | catalog/cases/case216_overload_added_beside_initializer_list/ |
| Rule family | overload-added-beside-initializer-list |
| Subject | Safe changes correctly not flagged |
Category: Overloads | Verdict: ✅ COMPATIBLE
Verdict and consumer impact¶
Negative control for
case111.
mylib::pick(int) and mylib::pick(std::initializer_list<int>) exist; v2
adds mylib::pick(double). pick(int) and pick(double) both accept {}
by the identity conversion, so judged as a pair they look ambiguous. But
the initializer_list overload ranks better for a braced argument
([over.ics.rank]/3.1), so mylib::pick({}) selects it before and after:
GCC and Clang return 2 both ways. Before the 2026-10-11 re-audit fix,
abicheck reported overload_ambiguity_introduced here.
Old/new diff¶
| v1.h | v2.h |
|---|---|
int pick(int);int pick(std::initializer_list<int>); |
same, plus int pick(double); |
abicheck command¶
g++ -shared -fPIC -g v1.cpp -o libv1.so
g++ -shared -fPIC -g v2.cpp -o libv2.so
abicheck compare libv1.so libv2.so --header old=v1.h --header new=v2.h
Expected abicheck finding¶
Same result with the CastXML and the Clang header backend
(ABICHECK_AST_FRONTEND=castxml|clang).
Minimum evidence¶
L0 (symbol table): the new pick(double) export alone shows the addition. The negative claim -- no overload_ambiguity_introduced -- is about the header tier, where the overload witness is computed.
Why abicheck catches it¶
The ambiguity witness is checked against the whole overload set: another
overload taking std::initializer_list at the {} position wins the call,
so no ambiguity is claimed.
Runtime failure demonstration¶
g++ app.cpp -L. -l:libv1.so -Wl,-rpath,. -o app && ./app # pick({}) = 2
sed 's/v1.h/v2.h/' app.cpp > app2.cpp && g++ app2.cpp v2.cpp -o app2 && ./app2 # pick({}) = 2
Safe redesign¶
Nothing to fix: this is a compatible addition.
Source files¶
CMakeLists.txtapp.cppv1.cppv1.hv2.cppv2.h
See also: Compatibility Catalog · All COMPATIBLE cases · Category: Addition (Compatible) · Rule: Overload added beside an initializer_list overload · Subject: Safe changes correctly not flagged.