Annex F (informative)
Core undefined behavior
[ub]
F.3
[expr]
: Expressions
[ub.expr]
F.3.12
[ub:expr.ref.member.not.similar]
Specified in:
[expr.
ref]
1
#
In a class member access
E1
.
E2
, where
E2
is a non-static member, the behavior is undefined if
E1
refers to an object whose type is not similar to the type of the expression
E1
.
2
#
[
Example
1
:
struct
A
{
int
i;
}
;
struct
B
{
int
j;
}
; A a;
int
x
=
reinterpret_cast
<
B
&
>
(
a
)
.
j;
// undefined behavior
—
end example
]