Skip to content

Case 123 โ€” Default Argument Removed

Field Value
Verdict ๐ŸŸ  API_BREAK
Category API Break
Platforms Linux
Flags API break
Detected ChangeKinds param_default_value_removed
Source files examples/case123_default_argument_removed/

Verdict: ๐ŸŸ  API_BREAK abicheck verdict: API_BREAK (with headers) / NO_CHANGE (object/ELF-only)

What changes

Version Declaration
v1 int connect(const char *host, int timeout_ms = 5000);
v2 int connect(const char *host, int timeout_ms);

The default value for timeout_ms is removed. The mangled symbol is identical (default arguments do not participate in name mangling).

What breaks

Any caller that relied on the default โ€” connect("example.org") โ€” no longer compiles against v2 (too few arguments to function). Already-compiled binaries keep linking and running. A pure source/API break. See app.cpp.

Why this case exists โ€” invisible to object analysis

Default-argument values live only in the declaration (the header). They are not encoded in the symbol name, DWARF, or anywhere in the object file โ€” the v1 and v2 .so are ABI-identical. abicheck detects this only in header mode, where castxml exposes the default="5000" attribute (ChangeKind param_default_value_removed). In object/DWARF mode it reports NO_CHANGE.

(Changing a default value rather than removing it is reported as the compatible-but-behavioural param_default_value_changed; adding a default is source-compatible and not flagged.)

Reproduce manually

g++ -shared -fPIC -g v1.cpp -o libnet_v1.so
g++ -shared -fPIC -g v2.cpp -o libnet_v2.so
abicheck compare libnet_v1.so libnet_v2.so \
    --old-header v1.h --new-header v2.h   # โ†’ API_BREAK (param_default_value_removed)
abicheck compare libnet_v1.so libnet_v2.so # โ†’ NO_CHANGE (object-only)

How to fix

Keep the default, or add an overload (connect(host) forwarding to connect(host, 5000)) so existing call sites keep compiling.


Source files

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

See also: Examples overview ยท All API_BREAK cases ยท Category: API Break.