CHAPTER 13
Undefined Behaviour Semantics
Contributed by: Sorav Bansal, Indian Institute of Technology Delhi
13.1 Introduction
What is Undefined Behaviour or UB, and why do we need to discuss UB semantics? Let’s look at a few examples to understand this better. Consider a source expression in a high-level language like C, “x = y/z”. Now consider two machines with different ISAs (Instruction Set Architectures) and let’s assume that “x = divide y, z” is a common instruction on both ISAs that implements “x = y/z” in the assembly code. There is a subtle difference between the two ISAs however, in how they handle division-by-zero, i.e., the case when “z” evaluates to zero: on one machine, a division by zero causes a hardware exception (eventually ...
Get Compilers: Principles, Techniques, and Tools, Updated 2nd Edition by Pearson now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.