Bug 6311 – Some array ops aren't nothrow

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
druntime
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2011-07-14T02:32:00Z
Last change time
2013-06-06T19:10:05Z
Keywords
rejects-valid
Assigned to
nobody
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-07-14T02:32:51Z
void foo(int[] a) nothrow { a[] = a[]; // OK a[] = a[] + a[]; a[] += a[]; } void main() {} DMD 2.054 gives: test.d(3): Error: _arraySliceSliceAddSliceAssign_i is not nothrow test.d(4): Error: _arraySliceSliceAddass_i is not nothrow test.d(1): Error: function test.foo 'foo' is nothrow yet may throw
Comment #1 by lovelydear — 2012-04-25T03:42:25Z
The example code is incorrect because I get at compile time: Error: Array operation a[] + b[] not implemented Also the copy operation throws: void foo(int[] a, int[] b) { // a.length = b.length; a[] = b[]; } void main() { int[] u = [1,2,3]; int[] v = [4,5,6,7]; foo(u,v); } with: object.Exception@src\rt\arraycat.d(31): lengths don't match for array copy unless one uncomments the line that matches lengths. I'm not sure why the dynamic arrays don't automagically adjust their size (performance ?), though.
Comment #2 by k.hara.pg — 2013-06-06T19:10:05Z
*** This issue has been marked as a duplicate of issue 8651 ***