25.3.12 Conversion of Union Member Accessed Using Member with Different Type

If a union defines several members of different types and you use one member identifier to try to access the contents of another (whether any conversion is applied to the result) is implementation-defined behavior in the standard. In the CCI, no conversion is applied and the bytes of the union object are interpreted as an object of the type of the member being accessed, without regard for alignment or other possible invalid conditions.

Example

The following shows an example of a union defining several members.

union {
	signed char code;
	unsigned int data;
	float offset;
} foobar;
Code that attempts to extract offset by reading data is not guaranteed to read the correct value.
float result;
result = foobbar.data;

Differences

All compilers have not converted union members accessed via other members.

Migration to the CCI

No action required.