[Issue 18934] std.concurrency receive throws assertion failure if message is a struct of struct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Jun 4 11:49:47 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=18934

Steven Schveighoffer <schveiguy at yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |schveiguy at yahoo.com
           Assignee|nobody at puremagic.com        |schveiguy at yahoo.com

--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> ---
The issue comes from std.variant.Variant checking the wrong thing when it comes
to constancy.

A smaller test case:

import std.variant;
import std.stdio;

struct S
{
    const int x;
}
void main()
{
    Variant v = S(1);
    writeln(v.get!S); // error
}

The issue is with the check inside std.variant to see if you can copy the given
type to the requested type. The type matches, but the copy would normally fail
because you can't overwrite const data.

However, in the case of v.get!S, it's a move and not a copy. The check should
be on moving the data, not copying. I have tested a fix, will submit a PR.

--


More information about the Digitalmars-d-bugs mailing list