4 ms·
> You can get along just fine in C++ without knowing the exact aliasing rules from C Nope, you can't. These are exactly the things that introduce undefined beh
by 0815test 7y ago
> You can get along just fine in C++ without knowing the exact aliasing rules from C
Nope, you can't. These are exactly the things that introduce undefined behavior (i.e. total breakage) if you aren't very careful about what you're doing at all times. Don't take my word for it, check out what the C++ designers themselves state about the issue in the C++ Core Guidelines. C/C++ is far from simple, and thinking that you can just make things up as you go along is a serious mistake.
- ogoffart 7y agoYou are absolutely right, but my point is that when you do modern C++, in the application code, it is very unlikely that you need to use reinterpret_cast in your code, and therefore you don't need to know all the subtlety about it. So despite C++ being more complex than C, if you limit yourself to some practical subset, it is actually easier than C.
- seba_dos1 7y agoSame can be (and has been) said about JavaScript. Or C. Or any language with any kind of issues. And it doesn't work in practice.
- Leherenn 7y agoI think it does sometimes? At least for enterprise software. We use both C and C++ embedded as well as C++/Qt for the desktop control system, and we have no issue keeping to a sane subset of C++. There are clearly defined rules and code review does the remaining enforcement. And it's not even hard or time consuming as everyone is pretty much aligned and every small issue can be easily resolved with a quick chat.