nothrow functions/methods

bearophile bearophileHUGS at lycos.com
Sun Feb 28 10:38:10 PST 2010


Daniel Murphy:
> Allocations are allowed inside nothrow functions.  If I remember correctly, the reasons are that disallowing them would limit usefulness, and that OutOfMemoryError is not generally recoverable.<

OK. Then can you tell me why the following program produces:
test2.d(1): Error: function test2.foo 'foo' is nothrow yet may throw

nothrow void foo() {
    auto a = new int[5];
}
void main() {}

Bye,
bearophile



More information about the Digitalmars-d mailing list