Skip to content

Commit 0db7033

Browse files
committed
Remove incorrect class.union.assignment.not.start.lifetime
1 parent 51fd05f commit 0db7033

File tree

2 files changed

+1
-32
lines changed

2 files changed

+1
-32
lines changed

source/classes.tex

+1-1
Original file line numberDiff line numberDiff line change
@@ -3237,7 +3237,7 @@
32373237
each anonymous union member \tcode{X}\iref{class.union.anon} that
32383238
is a member of a union and
32393239
has such an element as an immediate subobject (recursively),
3240-
if modification of \tcode{X} would have undefined behavior\ubdef{class.union.assignment.not.start.lifetime} under~\ref{basic.life},
3240+
if modification of \tcode{X} would have undefined behavior under~\ref{basic.life},
32413241
an object of the type of \tcode{X} is implicitly created
32423242
in the nominated storage;
32433243
no initialization is performed and

source/ub.tex

-31
Original file line numberDiff line numberDiff line change
@@ -1242,37 +1242,6 @@
12421242
\end{example}
12431243

12441244

1245-
\rSec2[ub.class.union]{Unions}
1246-
1247-
\pnum
1248-
\ubxref{class.union.assignment.not.start.lifetime} \\
1249-
Assigning to a union member may not start its lifetime, in that case using it will result in undefined behavior.
1250-
1251-
\pnum
1252-
\begin{example}
1253-
\begin{codeblock}
1254-
struct X {
1255-
const int a;
1256-
int b;
1257-
};
1258-
1259-
union Y {
1260-
X x;
1261-
int k;
1262-
};
1263-
1264-
void g() {
1265-
Y y = {{1, 2}}; // OK, \tcode{y.x} is active union member\iref{class.mem}
1266-
int n = y.x.a;
1267-
y.k = 4; // OK, ends lifetime of \tcode{y.x}, \tcode{y.k} is active member of union
1268-
y.x.b = n; // undefined behavior: \tcode{y.x.b} modified outside its lifetime,
1269-
// \tcode{S(y.x.b)} is empty because \tcode{X}'s default constructor is deleted,
1270-
// so union member \tcode{y.x}'s lifetime does not implicitly start
1271-
}
1272-
\end{codeblock}
1273-
\end{example}
1274-
1275-
12761245
\rSec2[ub.class.abstract]{Abstract classes}
12771246

12781247
\pnum

0 commit comments

Comments
 (0)