Open
Description
Chapter
Expressions
Guideline Title
Do not divide by 0
Category
Mandatory
Status
Draft
Release Begin
unclear
Release End
latest
FLS Paragraph ID
fls_Q9dhNiICGIfr
Decidability
Undecidable
Scope
System
Tags
numerics
Amplification
This guideline applies when unsigned integer or two’s complement division is performed.
Exception(s)
No response
Rationale
Integer division by zero results in a panic, which is an abnormal program state and may terminate the process.
Non-Compliant Example - Prose
When the division is performed, the right operand is evaluated to zero and the program panics.
Non-Compliant Example - Code
let x = 0;
let x = 5 / x;
Compliant Example - Prose
There is no compliant way to perform integer division by zero
Compliant Example - Code
let x = 5 / 5;