Bug 20797 – Destructor marked as nothrow renders try-catch block useless

Status
RESOLVED
Resolution
INVALID
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2020-05-05T04:04:13Z
Last change time
2020-05-05T09:40:24Z
Assigned to
No Owner
Creator
RazvanN

Comments

Comment #0 by razvan.nitu1305 — 2020-05-05T04:04:13Z
struct K { ~this() nothrow {} } void main() { static class C { this(K, int) {} } static int foo(bool flag) { if (flag) throw new Exception("hello"); return 1; } try { new C(K(), foo(true)); } catch(Exception) { } } Result: [email protected](18): hello Expected result: code does not throw exception.
Comment #1 by iamthewilsonator — 2020-05-05T04:35:37Z
Doesn't throw or doesn't catch the crown exception? I think it should throw and catch.
Comment #2 by razvan.nitu1305 — 2020-05-05T08:43:13Z
(In reply to Nicholas Wilson from comment #1) > Doesn't throw or doesn't catch the crown exception? I think it should throw > and catch. Yes, I meant, that the expected result is that code exits gracefully by throwing and catching exactly 1 exception.
Comment #3 by razvan.nitu1305 — 2020-05-05T09:40:24Z
Closing this. I was on a branch where I did some modifications to some other code. On git master it does this issue does not manifest.