Annex F (informative)
Core undefined behavior
[ub]
F.3
[expr]
: Expressions
[ub.expr]
F.3.3
[ub:expr.basic.lvalue.union.initialization]
Specified in:
[basic.
lval]
1
#
If a program invokes a defaulted copy/move constructor or defaulted copy/move assignment operator of a union with an argument that is not an object of a similar type within its lifetime, the behavior is undefined
.
2
#
[
Example
1
:
union
U
{
int
x;
}
;
void
f
(
)
{
char
u
[
sizeof
(
U
)
]
; U o
=
reinterpret_cast
<
U
&
>
(
u
)
;
// undefined behavior
}
—
end example
]