D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4327 - std.container.Array.Range.~this() tries to call free(T[])
Summary: std.container.Array.Range.~this() tries to call free(T[])
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: Other All
: P2 blocker
Assignee: Lars T. Kyllingstad
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-16 02:18 UTC by Lars T. Kyllingstad
Modified: 2010-08-11 02:46 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Lars T. Kyllingstad 2010-06-16 02:18:19 UTC
Example:

  Array!int a;

Error:

std/container.d(1660): Error: function core.stdc.stdlib.free (void* ptr) is not callable using argument types (int[])
std/container.d(1660): Error: cannot implicitly convert expression ((*this._data)._payload) of type int[] to void*

The fix is trivial, just add .ptr in line 1660:

-            free(_data._payload);
+            free(_data._payload.ptr);

But why aren't the unittests picking this up?  I've investigated a bit, and found that when Array!int is declared in the std.concurrency unittests, the int[] is implicitly cast to void* in the call to free().  However, this doesn't happen when Array!int is declared in user code.  Very strange.
Comment 1 Lars T. Kyllingstad 2010-06-16 02:37:33 UTC
http://www.dsource.org/projects/phobos/changeset/1651
Comment 2 Lars T. Kyllingstad 2010-08-11 02:46:29 UTC
Fixed DMD 2.048