Annex F (informative)
Core undefined behavior
[ub]
F.3
[expr]
: Expressions
[ub.expr]
F.3.13
[ub:expr.dynamic.cast.pointer.lifetime]
Specified in:
[expr.
dynamic.
cast]
1
#
Evaluating a
dynamic_
cast
on a non-null pointer that points to an object (of polymorphic type) of the wrong type or to an object not within its lifetime has undefined behavior
.
2
#
[
Example
1
:
struct
B
{
virtual
~
B
(
)
;
}
;
void
f
(
)
{
B bs
[
1
]
; B
*
dp
=
dynamic_cast
<
B
*
>
(
bs
+
1
)
;
// undefined behavior
}
—
end example
]