Index: docs/CodingStandards.rst =================================================================== --- docs/CodingStandards.rst +++ docs/CodingStandards.rst @@ -811,6 +811,20 @@ for (const auto *Ptr : Container) { observe(*Ptr); } for (auto *Ptr : Container) { Ptr->change(); } +Beware of non-determinism due to iteration order of unordered containers +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Unordered containers like SmallPtrSet, DenseMap and DenseSet do not have +a defined iteration order. As a result, iteration of such containers can +result in non-deterministic code generation. While the generated code +might not necessarily be "wrong code", this non-determinism might result +in unexpected runtime crashes or simply hard to reproduce bugs on the +customer side making it harder to debug and fix. + +As a rule of thumb, remember to sort an unordered container before +iteration. Or try using ordered containers like SmallVector or MapVector +in case iteration is needed. + Style Issues ============