File tree 2 files changed +1
-32
lines changed
2 files changed +1
-32
lines changed Original file line number Diff line number Diff line change 3237
3237
each anonymous union member \tcode {X}\iref {class.union.anon } that
3238
3238
is a member of a union and
3239
3239
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 },
3241
3241
an object of the type of \tcode {X} is implicitly created
3242
3242
in the nominated storage;
3243
3243
no initialization is performed and
Original file line number Diff line number Diff line change 1200
1200
\end {example }
1201
1201
1202
1202
1203
- \rSec 2[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
-
1234
1203
\rSec 2[ub.class.abstract]{Abstract classes}
1235
1204
1236
1205
\pnum
You can’t perform that action at this time.
0 commit comments