[previous] MISRA C:2012  Rule-21.12:  (Advisory) [next] The exception handling features of <fenv.h> should not be used

Amplification:

The identifiers feclearexcept, fegetexceptflag, feraiseexcept, fesetexceptflag and fetestexcept shall not be used and no macro with one of these names shall be expanded.

The macros FE_INEXACT, FE_DIVBYZERO, FE_UNDERFLOW, FE_OVERFLOW, FE_INVALID and FE_ALL_EXCEPT, along with any implementation-defined floating-point exception macros, shall not be used.

Example Code:


#include <fenv.h>

#include "misra.h"
#include "m3cmex.h"

extern int16_t rule_2112( void )
{
   float32_t z;
   s16a = feclearexcept( FE_DIVBYZERO );                /* 5136 */
   z = f32a / f32b;
   if ( fetestexcept( FE_DIVBYZERO ) != 0 )             /* 5136 */
   {
   }
   else
   {
#pragma STDC FENV_ACCESS ON                             /* 3116 */
       z = f32a * f32b;
   }
   if ( z > f32a )
   {
#pragma STDC FENV_ACCESS OFF                            /* 3116 */
       if ( fetestexcept( FE_OVERFLOW ) != 0)           /* 5136 */
       {
       }
   }

   return 1;
}


QAC messages that encompass this guideline:

5136 Use of exception handling identifier: feclearexcept, fegetexceptflag, feraiseexcept, fesetexceptflag or fetestexcept.



(c) The Motor Industry Research Association, 2012
QA C Source Code Analyser 8.1.2
MISRA C:2012 Compliance Module 1.0
© 2013 Programming Research
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents