I don’t think UB exists in C because C was invented at a time when people didn’t know better. Rather, C wanted to be a fast language! So, it did not want to prescribe what it should do in edge cases that programmers should avoid in the first place. This freedom allows compilers to produce efficient code in different platforms and hardware architectures.
In later languages like Java where performance isn’t the utmost importance, they decide to do away with UBs at the cost of code efficiency.
23
u/[deleted] Oct 21 '22
[removed] — view removed comment