digitalmars.D.learn - exceptions thrown by new / object constructor ?
- Michal Minich <michal.minich gmail.com> Nov 01 2010
- Kagamin <spam here.lot> Nov 01 2010
- Michal Minich <michal.minich gmail.com> Nov 01 2010
- Jesse Phillips <jessekphillips+D gmail.com> Nov 01 2010
- Don <nospam nospam.com> Nov 02 2010
- Michal Minich <michal.minich gmail.com> Nov 02 2010
What exceptions can be throw by object constructor / new expression?
Following code fails to compile because compiler says that both functions
foo and bar can throw.
class C {
nothrow this () {}
}
nothrow void foo () {
auto c = new C;
}
nothrow void bar () {
auto o = new Object;
}
Nov 01 2010
Michal Minich Wrote:What exceptions can be throw by object constructor / new expression? Following code fails to compile because compiler says that both functions foo and bar can throw. class C { nothrow this () {} } nothrow void foo () { auto c = new C; } nothrow void bar () { auto o = new Object; }
GC can throw OutOfMemoryException
Nov 01 2010
On Mon, 01 Nov 2010 15:17:11 -0400, Kagamin wrote:Michal Minich Wrote:What exceptions can be throw by object constructor / new expression? Following code fails to compile because compiler says that both functions foo and bar can throw. class C { nothrow this () {} } nothrow void foo () { auto c = new C; } nothrow void bar () { auto o = new Object; }
GC can throw OutOfMemoryException
http://www.digitalmars.com/d/2.0/phobos/std_gc.html in GC docs it says it throw OutOfMemoryException, but shouldn't that be OutOfMemoryError ? Isn't the docs just outdated...?
Nov 01 2010
I thought there was a Bug report on this, but I guess not. I say report it. Ether it should compile or the compiler should error that a constructor can not be nothrow.
Nov 01 2010
Jesse Phillips wrote:I thought there was a Bug report on this, but I guess not. I say report it. Ether it should compile or the compiler should error that a constructor can not be nothrow.
This has already been fixed in svn, and will be in the next release. See bug 3020. nothrow is painful and limited in 2.050, but should be quite usable in 2.051.
Nov 02 2010
On Tue, 02 Nov 2010 15:58:51 +0100, Don wrote:Jesse Phillips wrote:I thought there was a Bug report on this, but I guess not. I say report it. Ether it should compile or the compiler should error that a constructor can not be nothrow.
This has already been fixed in svn, and will be in the next release. See bug 3020. nothrow is painful and limited in 2.050, but should be quite usable in 2.051.
Great! Many thanks! This issue has greatly limited nothrow usage because 'new' is so common.
Nov 02 2010









Michal Minich <michal.minich gmail.com> 