Bug 3864 – Dyn array allocations can be allowed in nothrow functions

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2010-02-28T14:06:00Z
Last change time
2015-06-09T01:27:41Z
Assigned to
nobody
Creator
bearophile_hugs
Blocks
4297

Comments

Comment #0 by bearophile_hugs — 2010-02-28T14:06:51Z
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 by michal.minich — 2010-02-28T17:32:40Z
similar cases: does no compile void foo1 () nothrow { auto x = [4]; } compiles ok void foo2 () nothrow { int[] x; x ~= 4; }
Comment #2 by clugdbug — 2010-11-08T19:11:30Z
Fixed svn 726.