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


--- Comment #0 from bearophile_hugs eml.cc 2012-05-25 13:56:47 PDT ---
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


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2012-09-22 22:22:46 PDT ---
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



--- Comment #2 from github-bugzilla puremagic.com 2012-09-22 23:43:35 PDT ---
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



--- Comment #3 from github-bugzilla puremagic.com 2012-09-24 07:47:09 PDT ---
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
Merge pull request #1138 from 9rnsr/fix8150

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 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


--- Comment #4 from bearophile_hugs 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?

-- 
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 "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


 --- Comment #4 from bearophile_hugs 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
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


--- Comment #5 from monarchdodra gmail.com 2012-09-24 22:59:42 PDT ---
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



--- Comment #6 from Kenji Hara <k.hara.pg gmail.com> 2012-09-25 06:51:38 PDT ---
(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. -- 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



--- Comment #7 from Kenji Hara <k.hara.pg gmail.com> 2012-09-25 06:56:50 PDT ---
(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. -- 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



--- Comment #8 from monarchdodra gmail.com 2012-09-25 07:04:01 PDT ---
(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 :) -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 25 2012