https://issues.dlang.org/show_bug.cgi?id=23472
Issue ID: 23472 Summary: scope(sucess) generate exception handling code. Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nob...@puremagic.com Reporter: deadal...@gmail.com See sample code: char inc(string s, ref int i) { scope(success) i++; return s[i]; } void main() { int i; inc("string", i); } The codegen using LDC is: char example.inc(immutable(char)[], ref int): push rbx mov rbx, rdx movsxd rcx, dword ptr [rdx] cmp rdi, rcx jbe .LBB0_1 mov al, byte ptr [rsi + rcx] add ecx, 1 mov dword ptr [rbx], ecx pop rbx ret .LBB0_1: mov r8, rdi lea rsi, [rip + .L.str] mov edi, 14 mov edx, 3 call _d_arraybounds_index@PLT cmp edx, 1 jne .LBB0_7 mov rdi, rax call _d_eh_enter_catch@PLT mov rdi, rax call _d_throw_exception@PLT .LBB0_7: add dword ptr [rbx], 1 mov rdi, rax call _Unwind_Resume@PLT mov rdi, rax call _Unwind_Resume@PLT It contains exception handling code, which shouldn't be required for a scope(success) statement, and in fact, we can see that the exception is caught and rethrown immediately. Checking with GDC and DMD shows that they also contain exception handling code, so I assume this is being generated by the frontend. --