2 ms·
I've been quoting C99 and my answers should be considered in that context. However, to say C99 does not "consider threading at all" is to neglect that the stan
by mlyle 7y ago
I've been quoting C99 and my answers should be considered in that context. However, to say C99 does not "consider threading at all" is to neglect that the standards body document above explicitly mentions the thread of execution... in the quote that I stated.
You seem to not be reading what I'm saying and also to be arguing with things I never asserted. e.g.
> Volatile is not sufficient to make double-checked locking safe.
OK, but I didn't say volatile makes double-checked locking safe... I said that the compiler's ability to reorder non-qualified variable accesses is "a big part of why" double-checked locking is an antipattern. My statement:
> Actually, you promise not to change things from another thread..., let alone a const! The compiler loads things into registers and has no way to know if memory in a passed reference changes underneath the hood... It can freely make optimizations that lead to incorrect computation, infinite loops, segmentation faults if this is not obeyed. If you've ever head about how "double check locking" is an antipattern, this is a big part of why.