Unicorn with delicious cookie
Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V2634. MISRA. Features from <fenv.h&…
menu mobile close menu
Analyzer diagnostics
General Analysis (C++)
General Analysis (C#)
General Analysis (Java)
Micro-Optimizations (C++)
Diagnosis of 64-bit errors (Viva64, C++)
Customer specific requests (C++)
MISRA errors
AUTOSAR errors
OWASP errors (C++)
OWASP errors (C#)
OWASP errors (Java)
Problems related to code analyzer
Additional information
toggle menu Contents

V2634. MISRA. Features from <fenv.h> should not be used.

Apr 04 2025

This diagnostic rule is based on the MISRA (Motor Industry Software Reliability Association) software development guidelines.

This diagnostic rule is relevant only for C.

Avoid using functions or macros from the <fenv.h> header file. In some cases, using the functionality of this file may result in unspecified or undefined behavior.

Below are some potential issues that can arise when working with <fenv.h>.

Issue N1. The order in which floating-point exception flags are set when calling feraiseexcept is not specified.

Issue N2. Calling fesetenv and/or feupdateenv with an argument that was not obtained via feholdexcept / fegetenv, or by expanding the FE_DFL_ENV macro leads to undefined behavior.

Issue N3. Some implementations of functions from the <math.h> header support rounding floating-point numbers only to the nearest representable value (FE_TONEAREST). If a different rounding mode is set, the result of calling such functions can be unpredictable.

The examples where the analyzer issues warnings:

void clear_overflow_status()
{
  feclearexcept(FE_OVERFLOW);
}

void change_rounding_direction()
{
  fesetround(FE_DOWNWARD);
}

double some_computation(void)
{
  int r = feraiseexcept(FE_OVERFLOW | FE_INEXACT);
  printf("feraiseexcept() %s\n", (r?"fails":"succeeds"));
  return 0.0;
}

This diagnostic is classified as:

  • MISRA-C-21.12
close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
** By clicking this button you agree to our Privacy Policy statement
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
* By clicking this button you agree to our Privacy Policy statement

close form
Free PVS‑Studio license for Microsoft MVP specialists
* By clicking this button you agree to our Privacy Policy statement

close form
To get the licence for your open-source project, please fill out this form
* By clicking this button you agree to our Privacy Policy statement

close form
I want to join the test
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam