Casting an integer to a pointer is implementation defined, not UB.
And every sane implementation does what everyone expects because its how memory mapped IO works (but you probably want a volatile in there and maybe a compiler or memory barrier as well depending on what the hardware guarantees about the access patterns for that particular range of addresses)
Generic things are rarely efficient, the most optimal code tends to be specialized and tailored to specific hardware and/or the kind of data its operating on.
std::vector (which is a really inefficient way of doing dynamic arrays btw) can be cleanly implemented with macros (see stb stretchy buf) or by splitting the element data from the housekeeping data:
The output of AI's is essentially lossy, so when you feed that back in as an autonomous loop you get the equivalent of a 100x re-saved jpeg, aka complete garbage.
A 1000 line long dependency file full of random literally whos code doing god knows what does not instill alot of confidence when I want to build and audit security critical programs.
I think this is why I'm so bored with modern video games - they all look the same - Unreal Engine, lots of same type of foliage and rubble and "background art" everywhere - take a random screenshot from a random aaa game and I couldn't tell one from the other.
And every sane implementation does what everyone expects because its how memory mapped IO works (but you probably want a volatile in there and maybe a compiler or memory barrier as well depending on what the hardware guarantees about the access patterns for that particular range of addresses)