The following sometimes fails after compiling for x86 with Visual Studio 16.8.1:
#include <cassert>
#include <cstdint>
struct X { uint64_t value; };
int main() {
X x;
assert(reinterpret_cast<uintptr_t>(&x) % alignof(X) == 0);
}
Interestingly, the assert doesn't trigger if X
has an explicit alignment specifier: struct alignas(uint64_t) X
.
Am I correct to assume this is a compiler bug and not some quirk of the C++ standard?