D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 3864 - Dyn array allocations can be allowed in nothrow functions
Summary: Dyn array allocations can be allowed in nothrow functions
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks: 4297
  Show dependency treegraph
 
Reported: 2010-02-28 14:06 UTC by bearophile_hugs
Modified: 2015-06-09 01:27 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description bearophile_hugs 2010-02-28 14:06:51 UTC
This program performs a memory allocation, so it can throw an out of memory error. But such exceptions are now meant to be not recoverable, so I think allocating memory can now be done in nothrow functions too.

But currently with the following code the compiler prints at compile time:
test2.d(1): Error: function test2.foo 'foo' is nothrow yet may throw


nothrow void foo() {
    auto a = new int[5];
}
void main() {}
Comment 1 Michal Minich 2010-02-28 17:32:40 UTC
similar cases:

does no compile
void foo1 () nothrow { auto x = [4]; }

compiles ok
void foo2 () nothrow { int[] x; x ~= 4; }
Comment 2 Don 2010-11-08 19:11:30 UTC
Fixed svn 726.