8000 Fix undefined node_hash_map<T>::EMPTY at link time (Debug and macOS builds) by schulzchristian · Pull Request #173 · KaHIP/KaHIP · GitHub
[go: up one dir, main page]

Skip to content

Fix undefined node_hash_map<T>::EMPTY at link time (Debug and macOS builds) - #173

Merged
schulzchristian merged 1 commit into
masterfrom
fix-node-hash-map-empty
Nov 13, 2026
Merged

schulzchristian merged 1 commit into
masterfrom
fix-node-hash-map-empty

Conversation

@schulzchristian
Copy link
Copy Markdown
Member

Fixes a link error introduced in v3.26 (PR #171).

lib/data_structure/node_hash_map.h declares static const NodeID EMPTY = std::numeric_limits<NodeID>::max(); inside the class template. grow() passes it by const reference (std::vector<NodeID> old_keys(cap, EMPTY)), which odr-uses the member. In C++11 (the project's standard) an odr-used in-class initialized static const member needs a definition outside the class. Release builds happen to inline the value, so CI passed, but Debug builds and the Homebrew build on macOS fail to link node_ordering (and other targets) with undefined reference to node_hash_map<T>::EMPTY.

Fix: add the out-of-class definition after the class:

template <typename V>
const NodeID node_hash_map<V>::EMPTY;

Behaviour is unchanged (same value; Release code is the same).

Verification:

  • Reproduced on Linux with -DCMAKE_BUILD_TYPE=Debug: before, node_ordering fails to link with undefined node_hash_map<unsigned int>, <int>, <moved_index> and <char>::EMPTY; after, all targets build.
  • The Debug node_ordering runs to completion on examples/example_weighted.graph; Debug kaffpa --k=4 --preconfiguration=fast on examples/delaunay_n15.graph gives a valid partition.
  • I checked the other static const members added in kaffpa: 3.9x less total time (2.8x geometric mean) at unchanged partition quality #171: stamped_node_map::MAX_STORES is only used by value, and the allocator constants are namespace-scope definitions, so this is the only case.

grow() passes EMPTY by const reference (std::vector<NodeID>(cap, EMPTY)), which
odr-uses it. In C++11 an in-class initialized static const member then needs a
definition outside the class. Release builds inline it, so CI passed, but Debug
builds (and the Homebrew build on macOS) fail to link node_ordering and other
targets with undefined node_hash_map<T>::EMPTY. No change in behaviour.
@schulzchristian
schulzchristian merged commit 8e4e9c8 into master Nov 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0