Repository navigation
Fix undefined node_hash_map<T>::EMPTY at link time (Debug and macOS builds) - #173
Merged
Merged
Conversation
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.
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.
Fixes a link error introduced in v3.26 (PR #171).
lib/data_structure/node_hash_map.hdeclaresstatic 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 linknode_ordering(and other targets) withundefined reference to node_hash_map<T>::EMPTY.Fix: add the out-of-class definition after the class:
Behaviour is unchanged (same value; Release code is the same).
Verification:
-DCMAKE_BUILD_TYPE=Debug: before,node_orderingfails to link with undefinednode_hash_map<unsigned int>,<int>,<moved_index>and<char>::EMPTY; after, all targets build.node_orderingruns to completion onexamples/example_weighted.graph; Debugkaffpa --k=4 --preconfiguration=fastonexamples/delaunay_n15.graphgives a valid partition.stamped_node_map::MAX_STORESis only used by value, and the allocator constants are namespace-scope definitions, so this is the only case.