FuSa C library isinf function promotes float to double

Hello!

I am using the ARM FuSa C library version 6.6.A and ARM compiler for Embedded FuSa 6.16.2.

I have a variable defined as float, that I am using with the isinf(x) macro defined in math.h. Compiler gives me this warning "warning: implicit conversion increases floating-point precision: 'float' to 'double' [-Wdouble-promotion]" with a note "note: expanded from macro 'isinf'". To my understanding the macro should check the size of the input and decide if it uses __ARM_isinf() or __ARM_isinff(). I check the size of the variable before and it is 4 like it should be for a float variable.

Why does it still give me that warning? How do I get rid of that warning without ignoring it?

RTL

Parents
  • Looking at the expansion of the macro

    #define isinf(x) \
        ((sizeof(x) == sizeof(float)) \
            ? __ARM_isinff(x) \
            : __ARM_isinf(x))

    Whe this expands in the code we'll end up with something like:

    ((sizeof(1.0f) == sizeof(float)) ? __ARM_isinff(1.0f) : __ARM_isinf(1.0f));

    So we'll end up with a warning for one of the branches even though it is never selected at runtime.

    I can't think of anything that will get rid of the warning without at least locally suppressing it.

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wdouble-promotion"
     ((sizeof(0.0) == sizeof(float)) ? __ARM_isinff(0.0) : __ARM_isinf(0.0));
    #pragma clang diagnostic pop

Reply
  • Looking at the expansion of the macro

    #define isinf(x) \
        ((sizeof(x) == sizeof(float)) \
            ? __ARM_isinff(x) \
            : __ARM_isinf(x))

    Whe this expands in the code we'll end up with something like:

    ((sizeof(1.0f) == sizeof(float)) ? __ARM_isinff(1.0f) : __ARM_isinf(1.0f));

    So we'll end up with a warning for one of the branches even though it is never selected at runtime.

    I can't think of anything that will get rid of the warning without at least locally suppressing it.

    #pragma clang diagnostic push
    #pragma clang diagnostic ignored "-Wdouble-promotion"
     ((sizeof(0.0) == sizeof(float)) ? __ARM_isinff(0.0) : __ARM_isinf(0.0));
    #pragma clang diagnostic pop

Children