Annex F (informative)
Core undefined behavior
[ub]
F.3
[expr]
: Expressions
[ub.expr]
F.3.26
[ub:expr.mptr.oper.not.contain.member]
Specified in:
[expr.
mptr.
oper]
1
#
Abbreviating
pm-expression
.
*
cast-expression
as
E1
.
*
E2
,
E1
is called the object expression
.
If the dynamic type of
E1
does not contain the member to which
E2
refers, the behavior is undefined
.
2
#
[
Example
1
:
struct
B
{
}
;
struct
D
:
B
{
int
x;
}
;
void
f
(
)
{
B
*
b
=
new
B; D
*
d
=
static_cast
<
D
*
>
(
b
)
;
int
D
::
*
p
=
&
D
::
x;
(
*
d
)
.
*
p
=
1
;
// undefined behavior, dynamic type
B
does not contain
x
}
—
end example
]