# V2605. MISRA. Features from <tgmath.h> should not be used.

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

This rule only applies to programs written in C. Functions or macros from the '<tgmath.h>' header file should not be used. They may lead to undefined behavior.

Look at the example:

    void bar(float complex fc)
    {
      ceil(fc); // undefined behavior
    }

The 'ceil' function call with an actual argument of the 'float complex' type leads to undefined behavior because the standard library does not contain a specialized version with such formal parameter type.

If a specialized function exists, it should be used to avoid such situations:

    #include <tgmath.h>

    float foo(float x)
    {
      return sin(x);
    }

For the 'sin' function, a specialized version with a formal argument of the 'float' type - 'sinf' type exists:

    #include <math.h>

    float foo(float x)
    {
      return sinf(x);
    }

This diagnostic is classified as:

MISRA-C-2012-21.11 MISRA-C-2023-21.11