Why is this an issue?
This is a draft version of a MISRA C++ 202x rule proposed for public review.
MISRA Rule 18.2.4
Analysis Type: Decidable,Single Translation Unit
offsetof macro is used to access the underlying representation of an object, breaking its encapsulation. In addition, its use
results in undefined behaviour when the specified member is a bit-field, a static data member, or a member function.
offsetof( A, i ); // Non-compliant
Copyright The MISRA Consortium Limited © 2023
S986 targets the same defect as this rule but for a non-mission-critical context.