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 rule is classified as:
|
Was this page helpful?
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: