AutosarC++17_03-M18.2.1¶
The macro offsetof shall not be used
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
Rationale
Use of this macro can lead to undefined behaviour when the types of the operands are incompatible, or when bit fields are used.
Example
#include <cstddef>
struct A
{
int32_t i;
};
void f1 ( )
{
offsetof ( A, i ); // Non-compliant
}
Note
For legal reasons, this rule’s description is not part of the public documentation.