Every ClassFactory getter (e.g. GetReconstructionFactory(), MFP_reconstruction.cpp:29) returns a reference to a function-local static singleton, but most use sites assign the result to a value:
// MFP_eulerian.cpp:19 — and the same pattern at ~8 other sites
ClassFactory rfact = GetReconstructionFactory();
This silently copy-constructs a snapshot of the whole registry (multimap nodes, key strings, std::function builders) instead of aliasing the singleton.
Impact today: none — all copies are taken after static-init registration completes, are only read (Build/getKeys), and live in cold config-time code. Behaviour is correct.
Why fix it anyway:
- Calling Register(...) on one of these copies would silently discard the registration — a natural-looking future mistake with no error or warning.
- A copy taken during static initialisation would snapshot a half-populated registry (the ordering problem the getter idiom exists to avoid).
Fix: change the assignments to auto& rfact = ... (one word per site, behaviour-identical). Known sites: MFP_eulerian.cpp:19, MFP_hydro.cpp:75,96,232, MFP_field.cpp:233,256, MFP_chargedparticle.cpp:27, MFP_distribution.cpp:37 — grep = Get.*Factory() for the full list.
Every ClassFactory getter (e.g. GetReconstructionFactory(), MFP_reconstruction.cpp:29) returns a reference to a function-local static singleton, but most use sites assign the result to a value:
// MFP_eulerian.cpp:19 — and the same pattern at ~8 other sites
ClassFactory rfact = GetReconstructionFactory();
This silently copy-constructs a snapshot of the whole registry (multimap nodes, key strings, std::function builders) instead of aliasing the singleton.
Impact today: none — all copies are taken after static-init registration completes, are only read (Build/getKeys), and live in cold config-time code. Behaviour is correct.
Why fix it anyway:
Fix: change the assignments to auto& rfact = ... (one word per site, behaviour-identical). Known sites: MFP_eulerian.cpp:19, MFP_hydro.cpp:75,96,232, MFP_field.cpp:233,256, MFP_chargedparticle.cpp:27, MFP_distribution.cpp:37 — grep = Get.*Factory() for the full list.