Commit 7c4e174
authored
Reset the proxy when the destructor of the underlying pointer throws (#82)
* Reset the proxy when the destructor of the underlying pointer throws
proxy::destroy() invoked destruction through an lvalue-qualified
overload, so the meta_resetting_guard that invoke_impl applies to
consuming overloads never ran. When the destructor of the underlying
pointer threw, the metadata still pointed at the destroyed object, so
has_value() stayed true and the next destruction ran on a dead object.
Every path that discards a value reached this: reset(),
operator=(nullptr), both branches of the copy assignment operator, the
move assignment operator, operator=(P&&) and both emplace overloads.
Destruction is a consuming operation like relocation, so give it the
same shape. The destroy meta now uses an rvalue-qualified overload,
which makes erased_context destroy the pointer through destroying_guard
and makes invoke_impl clear the metadata on both the normal and the
exceptional path. destroy_dispatch keeps only its tag role and its call
operator becomes a no-op, because the destruction it used to perform is
what the rvalue machinery already does.
The added reset is dead on the non-throwing path and the optimizer
removes it. At -O2 the disassembly of ~proxy, reset and the move
assignment operator is unchanged for a facade whose destructibility is
nothrow.
LifetimeTracker gains ThrowingDestructionSession, a Session whose
destructor throws, which is the first pointer in the suite with a
potentially throwing destructor and the first use of a facade whose
destructibility is nontrivial.
* Fix MSVC failure1 parent 07e6520 commit 7c4e174
4 files changed
Lines changed: 96 additions & 13 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | | - | |
389 | | - | |
390 | | - | |
| 388 | + | |
391 | 389 | | |
392 | 390 | | |
393 | 391 | | |
| |||
617 | 615 | | |
618 | 616 | | |
619 | 617 | | |
620 | | - | |
621 | | - | |
622 | | - | |
623 | | - | |
| 618 | + | |
624 | 619 | | |
625 | 620 | | |
626 | 621 | | |
| |||
925 | 920 | | |
926 | 921 | | |
927 | 922 | | |
928 | | - | |
929 | | - | |
| 923 | + | |
| 924 | + | |
930 | 925 | | |
931 | 926 | | |
932 | 927 | | |
| |||
1331 | 1326 | | |
1332 | 1327 | | |
1333 | 1328 | | |
1334 | | - | |
1335 | | - | |
| 1329 | + | |
| 1330 | + | |
1336 | 1331 | | |
1337 | 1332 | | |
1338 | 1333 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
81 | | - | |
| 81 | + | |
82 | 82 | | |
83 | 83 | | |
84 | 84 | | |
| |||
223 | 223 | | |
224 | 224 | | |
225 | 225 | | |
226 | | - | |
| 226 | + | |
227 | 227 | | |
228 | 228 | | |
229 | 229 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
29 | 37 | | |
30 | 38 | | |
31 | 39 | | |
| |||
274 | 282 | | |
275 | 283 | | |
276 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
277 | 300 | | |
278 | 301 | | |
279 | 302 | | |
| |||
358 | 381 | | |
359 | 382 | | |
360 | 383 | | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
361 | 408 | | |
362 | 409 | | |
363 | 410 | | |
| |||
630 | 677 | | |
631 | 678 | | |
632 | 679 | | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
633 | 708 | | |
634 | 709 | | |
635 | 710 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
8 | 9 | | |
9 | 10 | | |
10 | 11 | | |
| |||
38 | 39 | | |
39 | 40 | | |
40 | 41 | | |
| 42 | + | |
| 43 | + | |
41 | 44 | | |
42 | 45 | | |
43 | 46 | | |
| |||
74 | 77 | | |
75 | 78 | | |
76 | 79 | | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
77 | 90 | | |
78 | 91 | | |
79 | 92 | | |
| |||
0 commit comments