Annex F (informative)
Core undefined behavior
[ub]
F.3
[expr]
: Expressions
[ub.expr]
F.3.15
[ub:expr.static.cast.base.class]
Specified in:
[expr.
static.
cast]
1
#
A glvalue of type
B
can be cast to the type “reference to
D
” if
B
is a base class of
D
, otherwise the behavior is undefined
.
2
#
[
Example
1
:
struct
B
{
}
;
struct
D1
:
B
{
}
;
struct
D2
:
B
{
}
;
void
f
(
)
{
D1 d; B
&
b
=
d;
static_cast
<
D2
&
>
(
b
)
;
// undefined behavior, base class object of type
D1
not
D2
}
—
end example
]