https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92332
Jonathan Wakely <redi at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|WAITING |RESOLVED Resolution|--- |INVALID --- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Andrew Pinski from comment #1) > two things, > One is you are violating C++ aliasing rules I think. Right, you're creating a uint64_t but accessing two uint32_t objects. The uint32_t objects were never initialized, so have indeterminate values. That's why you get warnings about uninitialized data. It would work if you used an array of unsigned char or std::byte, since they have special aliasing rules that allow them to be used to read the bytes of other types. Also the static_cast<bar&> is undefined, because there is no bar object at that location, just a myarray<int32_t, 2>. > Second is after "operator new", the value that is contained in the pointer > is undefined/unspecified. I don't know what this means. > NOTE in C++2a (or c++20), there is an operator new which has the property of > the value is kept defined. (BUT GCC Does not implement that yet). I don't know what this means either. The code has undefined behaviour though, so closing.