> I understand the need for correct lock-free impls: Given OP's description, simply avoiding read mutexes can't be the way to go about it?
I did note that the documentation recommends a lock.
> read the first value ever set to the variable for the entire lifetime of the program
That is not my reading of the current memory model? It seems to specifically prohibit this behaviour in requirement 3:
> 2. w does not happen before any other write w' (to x) that happens before r.
> The happens before relation is defined as the transitive closure of the union of the sequenced before and synchronized before relations.
Without synchronization, the degenerate sequencing is perfectly valid.
That’s the problem with being “clever” - you miss a definition and your entire mental model is busted.
> I understand the need for correct lock-free impls: Given OP's description, simply avoiding read mutexes can't be the way to go about it?
I did note that the documentation recommends a lock.
> read the first value ever set to the variable for the entire lifetime of the program
That is not my reading of the current memory model? It seems to specifically prohibit this behaviour in requirement 3:
> 2. w does not happen before any other write w' (to x) that happens before r.