Annex F (informative)
Core undefined behavior
[ub]
F.3
[expr]
: Expressions
[ub.expr]
F.3.9
[ub:conv.ptr.virtual.base]
Specified in:
[conv.
ptr]
1
#
Converting a pointer to a derived class
D
to a pointer to a virtual base class
B
that does not point to a valid object within its lifetime has undefined behavior
.
2
#
[
Example
1
:
struct
B
{
}
;
struct
D
:
virtual
B
{
}
;
void
f
(
)
{
D ds
[
1
]
; B
*
b
=
&
ds
[
1
]
;
// undefined behavior
}
—
end example
]