2 ms·
It's not like you stumble over UB in your daily work in C/C++, you know it exists, you know which areas to avoid, you compile and test on the 3 "big" compilers
by flohofwoe 8y ago
It's not like you stumble over UB in your daily work in C/C++, you know it exists, you know which areas to avoid, you compile and test on the 3 "big" compilers (gcc, clang, cl.exe). On clang, test with UBSan enabled.
UB isn't "crazyness" it's just a detail to be aware of.
A compiled binary that worked correctly won't suddenly run into undefined behaviour, that can only happen if you upgrade compiler versions or change compilation flags. But this only happens while the application is still actively developed and tested.
- the_why_of_y 8y agoThat presumes that your testing process will find the input that actually triggers the UB in your program before the release. The CVE history of the major browser vendors indicate that this is currently an unsolved problem for their large C++ applications.
- flohofwoe 8y agoOf course, and that's exactly where Rust makes sense. Few pieces of software are as safety-critical and complex as a browser though, that's why I'm not a fan of the general "UB scaremongering" ;)
- oconnor663 8y ago> A compiled binary that worked correctly won't suddenly run into undefined behaviour, that can only happen if you upgrade compiler versions... Upgrading the compiler version and causing undefined behavior sounds pretty sudden. Here's my favorite story along those lines: http://pzemtsov.github.io/2016/11/06/bug-story-alignment-on-x86.html http://pzemtsov.github.io/2016/11/06/bug-story-alignment-on-...
- humanrebar 8y ago> It's not like you stumble over UB in your daily work in C/C++... I don't know. I often help colleagues out with things like preprocessor nonsense and violations of the One Definition Rule. A lot of it has to do with difficult build and packaging tools. Actually standardizing a module system will be an important step in the right direction.
- s3cur3 8y agoFull-time C++ game dev of ~5 years here. I absolutely run into UB issues at least once a month, sometimes as often as a couple times in a week. I doubt our codebase is of below average quality either. UBsan is a godsend here... without it, this stuff was truly hell to debug.
- ilovecaching 8y agoIt isn't just UB. It's ADL, ODR, templates, multiple inheritance, etc. The de facto compatibility with C and its own backwards compatibility are also both curses on C++. C++ also blew their complexity budget in a lot of questionable ways that just makes it hard to keep C++ code maintainable. When things become unmaintainable, they become buggy.