Comment #4 by bearophile_hugs — 2012-09-24T09:50:47Z
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
What's the statement not not reachable at line 2?
(In reply to comment #4)
> 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
>
> What's the statement not not reachable at line 2?
This is diagnostic bug. I've opened new bug 8724.
Comment #7 by k.hara.pg — 2012-09-25T06:56:50Z
(In reply to comment #5)
> Could you also check that a nothrow constructor can still throw
> an Error please?
>
> From related: http://d.puremagic.com/issues/show_bug.cgi?id=8675
Nothrow check mechanism for the constructors is same as for normal functions, and that's already fixed by 8675. So, there is no problem.
Comment #8 by monarchdodra — 2012-09-25T07:04:01Z
(In reply to comment #7)
> (In reply to comment #5)
> > Could you also check that a nothrow constructor can still throw
> > an Error please?
> >
> > From related: http://d.puremagic.com/issues/show_bug.cgi?id=8675
>
> Nothrow check mechanism for the constructors is same as for normal functions,
> and that's already fixed by 8675. So, there is no problem.
Ok, thanks. Just double checking: wouldn't want to re-introduce a bug :)