Skip to content

Commit 0788337

Browse files
authored
Remove incorrect class.union.assignment.not.start.lifetime (#7833)
1 parent a6064c6 commit 0788337

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
@@ -1200,37 +1200,6 @@
12001200
\end{example}
12011201

12021202

1203-
\rSec2[ub.class.union]{Unions}
1204-
1205-
\pnum
1206-
\ubxref{class.union.assignment.not.start.lifetime} \\
1207-
Assigning to a union member may not start its lifetime, in that case using it will result in undefined behavior.
1208-
1209-
\pnum
1210-
\begin{example}
1211-
\begin{codeblock}
1212-
struct X {
1213-
const int a;
1214-
int b;
1215-
};
1216-
1217-
union Y {
1218-
X x;
1219-
int k;
1220-
};
1221-
1222-
void g() {
1223-
Y y = {{1, 2}}; // OK, \tcode{y.x} is active union member\iref{class.mem}
1224-
int n = y.x.a;
1225-
y.k = 4; // OK, ends lifetime of \tcode{y.x}, \tcode{y.k} is active member of union
1226-
y.x.b = n; // undefined behavior: \tcode{y.x.b} modified outside its lifetime,
1227-
// \tcode{S(y.x.b)} is empty because \tcode{X}'s default constructor is deleted,
1228-
// so union member \tcode{y.x}'s lifetime does not implicitly start
1229-
}
1230-
\end{codeblock}
1231-
\end{example}
1232-
1233-
12341203
\rSec2[ub.class.abstract]{Abstract classes}
12351204

12361205
\pnum

0 commit comments

Comments
 (0)