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 1242
1242
\end {example }
1243
1243
1244
1244
1245
- \rSec 2[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
-
1276
1245
\rSec 2[ub.class.abstract]{Abstract classes}
1277
1246
1278
1247
\pnum
You can’t perform that action at this time.
0 commit comments