As discovered during the review for Jonas Drewson's libcurl wrapper, std.concurrency (correctly, according to TDPL) accepts shared arrays, but cannot handle them internally:
---
import std.concurrency;
void main() {
auto tid = spawn(function(){});
send(tid, cast(shared(int)[])null);
}
---
---
std/variant.d(529): Error: function core.stdc.string.memcpy (void* s1, in const(void*) s2, uint n) is not callable using argument types (ubyte[32u]*,shared(int)*,uint)
std/variant.d(529): Error: cannot implicitly convert expression (& rhs) of type shared(int)* to const(void*)
---
From the error message, the problem seems std.variant trying to copy a shared(int) to another in its opIndex implementation using memcpy(&target, &source, source.sizeof). This fails because shared(int)* isn't implicitly convertible to const(void*).
The issue can also be demonstrated by the following example directly using std.variant:
---
import std.variant;
void main() {
shared(int)[] array;
auto v = Variant(array);
}
---
Comment #1 by dlang.element126 — 2014-04-22T21:31:32Z
This bug is still present in Phobos 2.065.0.
See: http://dpaste.dzfl.pl/79743d502b27
As pointed out by David, this seems to be caused by Variant trying to pass a shared(double)* to the C function stdc.string.memcpy (btw, it is not specific to double). The error message has now become more cryptic.
The same test case for Variant (http://dpaste.dzfl.pl/e0dcfdf241bb) now gives (truncated output for DMD):
---
/usr/include/dlang/dmd/std/variant.d(585): Error: function core.stdc.string.memcpy (void* s1, const(void*) s2, ulong n) is not callable using argument types (ubyte[32]*, shared(double)*, ulong)
/usr/include/dlang/dmd/std/variant.d(427): Error: template instance std.variant.VariantN!(32LU).VariantN.opAssign!(shared(double)) error instantiating
---
Comment #2 by dfj1esp02 — 2016-08-05T13:15:31Z
Also affected shared and immutable AAs. Ideally Variant should be covered for supported types and their shared and immutable variants.
Comment #3 by dfj1esp02 — 2017-08-22T16:16:57Z
std.concurrency problem is fixed in issue 13262, though don't know if it applies to all uses of variant.