Skip to content

Commit 6caf322

Browse files
authored
Update noexcept-trampolines.md
1 parent dad00ae commit 6caf322

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

exceptions/noexcept-trampolines.md

+16-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ struct HasDestructor {
4242
};
4343

4444
void fun() {
45-
HasDestructor hd;
45+
HasDestructor hd1;
4646
opaquePreamble();
47+
HasDestructor hd2;
4748
opaqueEpilog();
4849
}
4950
```
@@ -55,15 +56,29 @@ fun(): # @fun()
5556
lea rdi, [rsp + 8]
5657
call HasDestructor::HasDestructor() [complete object constructor]
5758
call opaquePreamble()
59+
mov rdi, rsp
60+
call HasDestructor::HasDestructor() [complete object constructor]
5861
call opaqueEpilog()
62+
mov rdi, rsp
63+
call HasDestructor::~HasDestructor() [complete object destructor]
5964
lea rdi, [rsp + 8]
6065
call HasDestructor::~HasDestructor() [complete object destructor]
6166
add rsp, 16
6267
pop rbx
6368
ret
6469
mov rbx, rax
70+
mov rdi, rsp
71+
call HasDestructor::~HasDestructor() [complete object destructor]
72+
jmp .LBB0_8
73+
jmp .LBB0_7
74+
.LBB0_7:
75+
mov rbx, rax
76+
.LBB0_8:
6577
lea rdi, [rsp + 8]
6678
call HasDestructor::~HasDestructor() [complete object destructor]
6779
mov rdi, rbx
6880
call _Unwind_Resume
6981
```
82+
You can see the size of the code itself, 15 assembler lines, is in the same order as the exception table, 10 assembler lines and 2 labels.
83+
84+
For our code to not care about calling destructors of local variables if an exception occurs the only way is to make it so the compiler can prove there are no exceptions, for that very consistent `noexcept` is needed.

0 commit comments

Comments
 (0)