I'm trying to do some static code analysis. Usually, my code uses tgmath.h to don't have to bother with all the maths fonctions variants.
The problem is that some tgmaths fonctions have complex number support, and even if I do not use complex numbers directly, some complex operator may appears in my code.
#include <tgmath.h>
int main(int argc, char **argv) {
sin(M_PI_2 - .8);
return 0;
}
expand to
int main(int argc, char **argv) {
__builtin_choose_expr (__builtin_classify_type(1.57079632679489661923132169163975144 - .8) == 9, __builtin_choose_expr(__builtin_types_compatible_p(__typeof__(__real__(1.57079632679489661923132169163975144 - .8)), long double), csinl(1.57079632679489661923132169163975144 - .8), __builtin_choose_expr((__builtin_types_compatible_p(__typeof__(__real__(1.57079632679489661923132169163975144 - .8)), double) || __builtin_classify_type(__real__(1.57079632679489661923132169163975144 - .8)) == 1), (csin)(1.57079632679489661923132169163975144 - .8), csinf(1.57079632679489661923132169163975144 - .8))), __builtin_choose_expr(__builtin_types_compatible_p(__typeof__(1.57079632679489661923132169163975144 - .8), long double), sinl(1.57079632679489661923132169163975144 - .8), __builtin_choose_expr((__builtin_types_compatible_p(__typeof__(1.57079632679489661923132169163975144 - .8), double) || __builtin_classify_type(1.57079632679489661923132169163975144 - .8) == 1), (sin)(1.57079632679489661923132169163975144 - .8), sinf(1.57079632679489661923132169163975144 - .8))));
return 0;
}
which contains some "__real__" operators.
The problem is in GRExprEngine::VisitUnaryOperator(). There is no case for UnaryOperator::Real and UnaryOperator::Imag. So when a Real operator is reached, the
assert (U->isIncrementDecrementOp()); is false.
What should be done to fix this ?