www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8150] New: Throwing nothrow struct constructor?

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150

           Summary: Throwing nothrow struct constructor?
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Keywords: accepts-invalid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



This compiles with no errors:


struct Foo {
    this(int) nothrow {
        throw new Exception("something");
    }
}
void main() {
    Foo(1);
}



DMD 2.060alpha gives at run-time:

object.Exception test.d(3): something

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 25 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/dmd/pull/1138
https://github.com/D-Programming-Language/druntime/pull/309

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150




Commit pushed to master at https://github.com/D-Programming-Language/druntime

https://github.com/D-Programming-Language/druntime/commit/cd1252036b41533ba5b132c99471e84d468d1f0b
Making Throwable and derived classes constructors  safe/pure/nothrow.

This is supplemental change for fixing issue 8150.
Constructing throwable object can be  sage, pure, and nothrow.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150




Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/c519a4d9dcc8b65aaadba2f30fdecf63bec5df99
fix Issue 8150 - Throwing nothrow struct constructor?

https://github.com/D-Programming-Language/dmd/commit/36e0a9b975941aac4bf5bd6fd044e6acbf2504e9


Issue 8150 - Throwing nothrow struct constructor?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 24 2012
prev sibling next sibling parent reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED



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?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 24 2012
parent "monarch_dodra" <monarchdodra gmail.com> writes:
On Monday, 24 September 2012 at 16:49:55 UTC, 
bearophile_hugs eml.cc wrote:
 http://d.puremagic.com/issues/show_bug.cgi?id=8150


 bearophile_hugs eml.cc changed:

            What    |Removed                     |Added
 ----------------------------------------------------------------------------
              Status|NEW                         |RESOLVED
          Resolution|                            |FIXED



 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
Sep 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |monarchdodra gmail.com



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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 24 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150





 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 25 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150





 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. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 25 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8150






 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 :) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 25 2012