Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always overwrite values in std::unordered_map objects #4476

Merged
merged 1 commit into from
Mar 16, 2022

Conversation

jngrad
Copy link
Member

@jngrad jngrad commented Mar 14, 2022

Fixes #4448

Affected code (all ESPResSo versions since 4.0.0):

  • Utils::Cache (used for particle caches)
  • Utils::Factory (used in the script interface registry)
  • Utils::NumeratedContainer (used in MPI callbacks)
  • ScriptInterface::AutoParameters (multiple parameter definitions didn't overwrite each other)
  • ScriptInterface::GlobalContext (risk of stale references being stored in MPI ranks >=1)
  • bond_breakage (multiple specifications didn't overwrite each other)

std::unordered_map<Key,T>::emplace(std::pair<Key, T> &&value) and
std::unordered_map<Key,T>::insert(std::pair<Key, T> &&value) actually
discard the new value if a value with the same key already exists.
@jngrad
Copy link
Member Author

jngrad commented Mar 15, 2022

This PR is needed for the upcoming electrostatics/magnetostatics refactoring PR.

@jngrad jngrad added automerge Merge with kodiak and removed automerge Merge with kodiak labels Mar 16, 2022
@jngrad jngrad merged commit a462268 into espressomd:python Mar 16, 2022
@jngrad jngrad deleted the fix-4448 branch March 16, 2022 14:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

std::unordered_map objects discard values with duplicate key
2 participants