This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MISRA C 2004 giving error on assigning pointer to float.



The C2000 MISRA C checker gives an error when I assign a float pointer to a float address as below:

float f32 = 0.0f;

float *fpointer = &f32;

This gives:

#1394-D (MISRA-C:2004 10.2/R) The value of an expression of floating type shall not be implicitly converted to a different type if the expression is complex

Even if I try to do explicitly cast it:

fpointer = ((float *)(&f32))

Then I get:

#1396-D (MISRA-C:2004 10.4/R) The value of a complex expression of floating type shall only be cast to a floating type that is narrower or of the same size

I can't seem to win! All I am doing is assigning the address of a pointer to a float pointer, which is exactly what it should hold. It this a compiler/analyzer bug?

Thanks,


Traver