Undefined Behavior deserves a better reputation

“Undefined Behavior” often has a bad reputation. But what, really, is Undefined Behavior, and is it actually that bad? In this blog post, I will look at this topic from a PL perspective…

Click to view the original at

Hasnain says:

I learnt a lot about language semantics from this one.

“In closing, I would like to propose that "Undefined Behavior" might need a rebranding. The term focuses on the negative case, when really all we ever care about as programmers or compiler authors is that programs do not have Undefined Behavior. Can we get rid of this double negation? Maybe we should talk about "ensuring Well-Defined Behavior" instead of "avoiding Undefined Behavior".

To sum up: most of the time, ensuring Well-Defined Behavior is the responsibility of the type system, but as language designers we should not rule out the idea of sharing that responsibility with the programmer.”

Posted on 2021-11-23T05:47:59+0000