Annex F (informative)
Core undefined behavior
[ub]
F.3
[expr]
: Expressions
[ub.expr]
F.3.14
[ub:expr.dynamic.cast.glvalue.lifetime]
Specified in:
[expr.
dynamic.
cast]
1
#
Evaluating a
dynamic_
cast
on a reference that denotes an object (of polymorphic type) of a type that is not similar to the referenced type or an object not within its lifetime has undefined behavior
.
2
#
[
Example
1
:
struct
B
{
virtual
~
B
(
)
;
}
;
void
f
(
)
{
B bs
[
1
]
; B
&
dr
=
dynamic_cast
<
B
&
>
(
bs
[
1
]
)
;
// undefined behavior
}
—
end example
]