On Tuesday, 5 May 2020 at 04:02:06 UTC, RazvanN wrote:
truct 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): helloIf the destructor of K is not marked nothrow the code does not throw an exception. Is this a bug or am I missing something?
Surely the above code, which silently discards the exception, does not print "hello"?
Regardless, I ran your code with writeln inside the catch(), and without the try-catch entirely, with and without nothrow on K's destructor. I am unable to replicate the issue on my computer with DMD 2.091.0, as well as on run.dlang.io. Is something missing in your code here?
-- Simen
