Is accessing registers through predefined static addresses undefined behaviour in C++?
问题 I'm compiling a C++ program to run in a freestanding environment and the CPU I'm running on defines a 32-bit peripheral register to be available ( edit: memory-mapped ) at PERIPH_ADDRESS (aligned correctly, and not overlapping with any other C++ object, stack etc.). I compile the following code with PERIPH_ADDRESS predefined, later link it with a full program and run it. #include <cstdint> struct Peripheral { const volatile uint32_t REG; }; static Peripheral* const p = reinterpret_cast