This is a bit of a language-lawyer question.
In a typical embedded system or device driver, it’s often necessary to make a very specific sequence of memory stores to MMIO/PIO registers. As an example:
store byte 0x10 to 0x40002000
store byte 0xaa to 0x40002001
It would not be correct, for example, to combine the writes (e.g. write the 16-bit quantity 0xaa10 to 0x40002000) nor to optimize the writes out if they are never read.
Usually in C, we would use volatile variables for this purpose:
*(volatile uint8_t *)0x40002000 = 0x10;
*(volatile uint8_t *)0x40002001 = 0xaa;
My question is this: in standard C++, is code like this guaranteed to result in the desired sequence of stores? If not, is there a way to guarantee such a sequence?
Answers should cite the standard (any version). If this is not possible (or not well-defined), please back that up with the standard.