[Issue 10740] New: std.concurrency send() fails with structs over 32 bytes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jul 31 21:44:12 PDT 2013


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

           Summary: std.concurrency send() fails with structs over 32
                    bytes
           Product: D
           Version: D2
          Platform: x86_64
        OS/Version: Linux
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: david at eagen.com


--- Comment #0 from David Eagen <david at eagen.com> 2013-07-31 21:44:11 PDT ---
Using 2.063.2 and 2.064-devel-333c6dd:

import std.concurrency : receiveOnly, send, thisTid;
import std.exception : assumeUnique;
import std.variant;

struct JustRight
{
    byte[32] j;
}

struct TooBig
{
    byte[33] t;
}

void main()
{
    JustRight[1] jArray;
    TooBig[1]    tArray;

    Variant vj = jArray[];
    Variant vt = tArray[];

    thisTid.send(vj);
    thisTid.send(vt);

    thisTid.send(assumeUnique(jArray[]));
    //thisTid.send(assumeUnique(tArray[])); // Fails to compile

    auto received = receiveOnly!((JustRight)[]);
}

If the send of tArray is commented out the compilation fails with:

src/phobos/std/variant.d(558): Error: cannot modify immutable expression *p

So, 32-byte structs can be sent (as arrays) using send or if you first wrap it
in an Variant object. Greater than 32-byte structs can be sent ONLY if they are
pre-wrapped in a Variant. The size of the data shouldn't limit it from being
sent using send().

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


More information about the Digitalmars-d-bugs mailing list