www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8724] New: Throwing exception in constructor prints strange warning

http://d.puremagic.com/issues/show_bug.cgi?id=8724

           Summary: Throwing exception in constructor prints strange
                    warning
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: diagnostic
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: k.hara.pg gmail.com



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 25 2012