NagyDonat wrote:

> That being said, do we know how exactly the unstable addresses result in 
> unstable results?

I cannot pinpoint the responsible code fragment, but in general this is a 
typical property of associative data structures. A typical associative map 
doesn't preserve the order of insertion, and instead stores the key-value pairs 
in some arbitrary order that facilitates quick and effective access (for 
example, many implementations sort them according to the keys -- or the hash 
values of the keys). When the program iterates over a data structure of this 
kind, it will see the key-value pairs in this arbitrary order, which may depend 
on pointer values, whose order relationships are undefined and may change if 
the program is reran with the same input. If the calculations performed by the 
loop are non-commutative (e.g. "sum all the values" is commutative, "return the 
first value which is larger than 10" is not), then this unstable iteration 
order produces unstable output.

By the way, the Python language (where performance is not prioritized) rules 
out these subtle bugs by recording the order of insertion within its `dict` 
(associative map) datatype and using that as the iteration order.

https://github.com/llvm/llvm-project/pull/121551
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to