Thread overview
[Issue 14551] scope(failure) block causes bloat in nothrow functions
Jan 17, 2020
Witold Baryluk
Jan 17, 2020
Witold Baryluk
Dec 17, 2022
Iain Buclaw
Feb 13, 2023
RazvanN
January 17, 2020
https://issues.dlang.org/show_bug.cgi?id=14551

Witold Baryluk <witold.baryluk+d@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |witold.baryluk+d@gmail.com

--- Comment #1 from Witold Baryluk <witold.baryluk+d@gmail.com> ---
http://asm.dlang.org/ looks to be down.

Would be nice to know actual example.

At least in gdc, I did found that `scope(failure)` in `nothrow` functions (or
even without manually indicating them as such) compiles to zero code, and is
eliminated to nothing.

However it doesn't warn about dead code, which IMHO it should.

Example:

```
int i = 0;

size_t f(string x) nothrow {
  scope(failure) i = 1;
  return 2 + x.length * x.length;
}

int main(string[] args) {
  return cast(int)f(args[1]);
}
```

Compiles with `gdc-9 -fno-bounds-check -O2 -Wall` to:


```
0000000000001230 <_Dmain>:
    1230:       48 8b 46 10             mov    0x10(%rsi),%rax
    1234:       48 0f af c0             imul   %rax,%rax
    1238:       48 83 c0 02             add    $0x2,%rax
    123c:       c3                      retq
    123d:       0f 1f 00                nopl   (%rax)
```

Wow.

--
January 17, 2020
https://issues.dlang.org/show_bug.cgi?id=14551

--- Comment #2 from Witold Baryluk <witold.baryluk+d@gmail.com> ---
Also it looks to be possibly similar issue to https://issues.dlang.org/show_bug.cgi?id=13575

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14551

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P4

--
February 13, 2023
https://issues.dlang.org/show_bug.cgi?id=14551

RazvanN <razvan.nitu1305@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |razvan.nitu1305@gmail.com
         Resolution|---                         |WONTFIX

--- Comment #3 from RazvanN <razvan.nitu1305@gmail.com> ---
The original code is not reachable anymore so we cannot fix this without a test case.

--