Skip to content

[Coding Guideline]: Do not divide by 0 #131

@vapdrs

Description

@vapdrs

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;

Metadata

Metadata

Assignees

Labels

category: mandatoryA coding guideline with category mandatorychapter: expressionscoding guidelineAn issue related to a suggestion for a coding guidelinedecidability: undecidableA coding guideline which cannot be checked automaticallyscope: systemA coding guideline that can be determined applied only when entire source is inspectedstatus: draft

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions