3 ms·
I can relate to that. I guess undefined behavior makes it somewhat harder to write correct software. I've definitely read someone make the same point. The prob
by svckr 9y ago
I can relate to that. I guess undefined behavior makes it somewhat harder to write correct software. I've definitely read someone make the same point.
The problem is, you can't always know if (for example) you're reading from an uninitialized variable, unless you run the program with the possibly infinite number of valid inputs, thereby also solving p != np.
In my opinion, undefined behavior is what we have and we had enough time to learn how to deal with it. If at all possible, compilers should be able to detect UB, so I can use compile flags to make UB an error. Changing the language to "define" undefined behavior, might turn it into unexpected behavior and I wouldn't like that.
At least we've learned the lesson with newer languages.
- pjmlp 9y ago> At least we've learned the lesson with newer languages. The thing is, we already knew that from older languages as well. C's UB is a consequence of the people involved in ANSI C89 not wanting to fully define the language, like the other languages were doing. I think the lesson is that "Performance trumps correctness" is the wrong path to follow, specially since not everyone using C is a 10x coder that always makes use of best practices.