https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49171
--- Comment #22 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to mark from comment #21) > The behavior here is non-portable, but well defined. If it wasn't, the > runtime reinterpret_cast would also be undefined. Why are/should constant > expressions be different? https://lists.isocpp.org/mailman/listinfo.cgi/std-discussion is a better place to ask that. GCC's bugzilla is not the place for it. > (In reply to Jonathan Wakely from comment #20) > > And doesn't exactly the same thing work fine in C++? > I don't understand the point. Yes, a C++ compiler will accept the C code. > But it will still be C, without the object-oriented advantages of C++ (the C > code has external functions taking struct pointers instead of instance > methods, etc, etc.) If you want member functions, this works fine: struct Addr { unsigned* const u; void set() const { *u = 0x87654321; } }; struct Addr addr = { (unsigned*)0x40000000 }; int main() { addr.set(); } > As I illustrated, it's impossible to have a C++ class > with an unsigned* const member pointing to an arbitrary memory address -- > and still have the object constexpr constructed/initialized in .data -- as > it is in C. See above.