C and C++ Binaries


LANG.ARITH.DIVZERO : Division By Zero

Summary

An attempt to perform integer division where the denominator evaluates to zero.

Properties

Class Name Division By Zero
Significance reliability
Mnemonic LANG.ARITH.DIVZERO
Categories
MisraC2023 MisraC2023:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
Misra2012 Misra2012:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
AUTOSARC++14 AUTOSARC++14:A5-6-1 The right hand operand of the integer division or remainder operators shall not be equal to zero.
MisraC++2023 MisraC++2023:4.1.3 There shall be no occurrence of undefined or critical unspecified behaviour
CWE CWE:369 Divide By Zero
  CWE:573 Improper Following of Specification by Caller
TS17961 TS17961:5.25-diverr 5.25. Integer division errors
CERT-C CERT-C:INT33-C Ensure that division and remainder operations do not result in divide-by-zero errors
DISA-3r10 DISA-3r10:V-16808 The designer will ensure the application is not vulnerable to integer arithmetic issues.
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Division By Zero"

Example

int divzero(void){
    int c = 5;
    int d;
    d = c*c - 20;       /* 'Unused Value' warning issued here
                         * - d is only used in a statement
                         *   that causes a program crash (via Division by Zero),
                         *   so CodeSonar considers it unused.
                         */
    return d  / (d-c);  /* 'Division By Zero' warning issued here */
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.