[Issue 8150] Throwing nothrow struct constructor?
monarch_dodra
monarchdodra at gmail.com
Mon Sep 24 22:59:11 PDT 2012
On Monday, 24 September 2012 at 16:49:55 UTC,
bearophile_hugs at eml.cc wrote:
> http://d.puremagic.com/issues/show_bug.cgi?id=8150
>
>
> bearophile_hugs at eml.cc changed:
>
> What |Removed |Added
> ----------------------------------------------------------------------------
> Status|NEW |RESOLVED
> Resolution| |FIXED
>
>
> --- Comment #4 from bearophile_hugs at eml.cc 2012-09-24 09:50:47
> PDT ---
> 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?
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
More information about the Digitalmars-d-bugs
mailing list