Bug 8724 – Throwing exception in constructor prints strange warning
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-09-25T06:51:00Z
Last change time
2015-02-18T03:36:56Z
Keywords
diagnostic
Assigned to
nobody
Creator
k.hara.pg
Comments
Comment #0 by k.hara.pg — 2012-09-25T06:51:11Z
From http://d.puremagic.com/issues/show_bug.cgi?id=8150#c4
Now compiling this code:
struct Foo {
this(int) nothrow { // line 2
throw new Exception("something");
}
}
void main() {
Foo(1);
}
It gives:
temp.d(3): Error: object.Exception is thrown but not caught
temp.d(2): Warning: statement is not reachable
temp.d(2): Error: constructor temp.Foo.this 'this' is nothrow yet may throw
Comment #1 by yebblies — 2013-11-24T05:22:28Z
No longer gives the warning.
Comment #2 by k.hara.pg — 2014-09-14T14:03:33Z
Works from 2.062. Probably it has been fixed by the fix for issue 9332.
Comment #3 by github-bugzilla — 2014-09-14T21:55:54Z