exceptions thrown by new / object constructor ?

Michal Minich michal.minich at gmail.com
Mon Nov 1 12:57:33 PDT 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...?


More information about the Digitalmars-d-learn mailing list