Instead of pointless arguing for particular cases, I guess I'll rather stress another important thing mentioned by mystran
... but this is not going to happen, because compiler writers ...
That is, when we say C++ in a sense of C++ Standard, do we actually remember that the standard from its very beginning was nothing but an attempt to reconcile various compiler manufactures and bring at least some order in? And since then none of compilers was bothered to actually 100% implement either of the standard versions... Why do you think they tell you if you go with "Psst! Guys, no more UBs since now?"
So a perfect language w/o UBs in a perfect world? Okay. In the real world this would just tear it (any non-VM language) into endless incompatible dialects (and then different languages) like "MSC++#", "GNU (read Intel) C++$", "Apple/BSD/Whatever C++©" etc etc. - getting more and more incompatible with each other each new day - so that by today you would not even be able to compile your code for each platform (same CPU! I'm not even talking of "exotics" like GPU/ARM/Endless DSPs and MCUs) w/o rewriting half of it first (and before you tell me you'd be fine to do it now
with one of them only (e.g. with GCC) I'll reply "think if it ever could get to that 'now' via that 'other way'").
I was not going to discuss anything but "aliasing" - and I'm afraid by now the thread has gone too deep into fantasy to take anything seriously (just like it was at viewtopic.php?f=33&t=481683
- yeah, everybody knows how a perfect language should look like but nobody ever gets one... surprise, surprise. The very fact that in our area of activity we still have
to heavily rely on something developed 50 years ago, with all of the outdated weirdness of that time visions and priorities, should ring some dreamer's bell).
Second, there can be systems where 0 is a perfectly valid memory address. Why can't I program for those systems in C++?
Oh, come on... Loss of 1 byte at the beginning of the memory space (in real
systems these regions are usually reserved for some whatever "internal hardware/system use" anyway and/or mapped to a virtual address values) is not equal to "I can't program for those systems".
- - -
P.S. In summary my position is that I'm absolutely fine with UBs if
it's the price for me being able to use the same language to develop for several CPU/DSP/MCU systems for all these years (and UBs were not even in the top10 of the problems I encountered while doing that).