www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6585] New: std.variant cannot handle shared arrays

http://d.puremagic.com/issues/show_bug.cgi?id=6585

           Summary: std.variant cannot handle shared arrays
           Product: D
           Version: D2
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: code klickverbot.at



---
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);
}
---

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 31 2011