C and C++


LANG.ARITH.FDIVZERO : Float Division By Zero

Summary

An attempt to perform floating-point division where the denominator evaluates to zero.

Properties

Class Name Float Division By Zero
Significance reliability
Mnemonic LANG.ARITH.FDIVZERO
Categories
MisraC2023 MisraC2023:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  MisraC2023:D.4.1 Run-time failures shall be minimized
Misra2012 Misra2012:1.3 There shall be no occurrence of undefined or critical unspecified behaviour
  Misra2012:D.4.1 Run-time failures shall be minimized
MisraC++2023 MisraC++2023:4.1.3 There shall be no occurrence of undefined or critical unspecified behaviour
CWE CWE:369 Divide By Zero
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
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="Float Division By Zero"

Example

float fdivzero(void){
    float c = 5.0;
    float d;
    d = c*c - 20.0;
    return d/(d-c);    /* 'Float Division by Zero' warning issued here */
}

Relevant Configuration File Parameters

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