4 ms·
> Not being able to do byte-granular writes means you simply can't implement things like this at all unless you: > 1) Decide that "char" will be 32 bits (i.e.,
by cwzwarich 7y ago
> Not being able to do byte-granular writes means you simply can't implement things like this at all unless you:
> 1) Decide that "char" will be 32 bits (i.e., make a byte on your system 4x larger than usual).
With the C++ memory model you can make std::atomic<char> larger than char. A lot of code assumes that this is not the case and that it is possible to cast between the two, but it's (surprise) undefined behavior.
- BeeOnRope 7y agoI'm not talking about atomic<char> but just plain char. Independent writes to two different plain char variables must not interfere. If those writes are implemented by reading 4 bytes, and/oring in the byte to write and then writing 4 bytes back, they will interfere.
- deleted 7y ago[deleted]