2 ms·
You are right that there's no inherent need for UB. However, we made the choice to have it. The reason to have it is the exact same reason that the distinction
by steveklabnik 8y ago
You are right that there's no inherent need for UB. However, we made the choice to have it.
The reason to have it is the exact same reason that the distinction between "implementation defined" and "undefined" exists in the first place: UB allows compilers to assume that it will never happen, and optimized based on it. That is a useful property, but it's a tradeoff, of course.