www.digitalmars.com         C & C++   DMDScript  

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


           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

--- Comment #0 from klickverbot <code klickverbot.at> 2011-08-31 18:39:54 PDT
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
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

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