Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Misra C:2004 Rule 12.12
#2
Hammer Wrote:I would like to know how to represent a Violation of rule 12.12.
It is stated in C90 that bitwise operands are required to of integer type. Therefore bitwise operators can't be used with floats to demonstrate this rule as this would be a direct violation of rule 1.1.

Is maybe pointer indirection using an unsigned char the answer?

or are there implementations that allow bitwise operators to be used with floats?

Thanks for your help!

Knowing what the physical layout of a particular floating point system is some people have a habit of reading byes out of a floating point number . This they believe saves time and space in converting the number properly. This is the practice we wanted to stop.

Rule 1.1 is there to make people itemise the diferences betwen the compiler in use and the ISO standard. No compiler inthe embedded world rigidly complies to ISO C and it would be impossible to program pure ISO C for large parts of any embedded system.

C is not strongly typed. Just because bit wise operators work on integers does not mean you cant get them to work on floats. This is the problem.

Why are you trying to produce an example of rule 21.12 violiation? The MISRA-C panel is producing an example suite at the moment. Could you not wait for that to come out?
<t>This post is made in a personal capacity<br/>
Member of MISRA-C-WG since 2002</t>


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)