AutosarC++18_10-M3.9.3

The underlying bit representations of floating-point values shall not be used

Required inputs: IR

[Implementation 3.9.1(8)]
Rationale

The storage layout used for floating-point values may vary from one compiler to another, and

therefore no floating-point manipulations shall be made which rely directly on the way the values are stored. The in-built operators and functions, which hide the storage details from the developer, should be used.

Example
float32_t My_fabs ( float32_t f ) 
{
uint8_t * pB = reinterpret_cast< uint8_t * >( &f );
*( pB + 3 ) &= 0x7f; // Non-compliant – generate the absolute value
// of an IEEE-754 float value.
return ( f );
}

Note

For legal reasons, this rule’s description is not part of the public documentation.