std.concurrency.send problems with immutable
Marek Janukowicz via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Aug 7 15:24:36 PDT 2015
This program works fine:
import std.concurrency;
struct A {
string a,b;
}
void main () {
immutable A a = immutable A( "blah" );
send( thisTid, a );
}
But if change struct A declaration to:
struct A {
string a,b,c;
}
I get this error during compilation:
/opt/dmd2/linux/bin64/../../src/phobos/std/variant.d(653): Error: cannot
modify immutable expression *p
/opt/dmd2/linux/bin64/../../src/phobos/std/variant.d(580): Error: template
instance std.variant.VariantN!32LU.VariantN.opAssign!(immutable(A)) error
instantiating
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(117):
instantiated from here: __ctor!(immutable(A))
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(628):
instantiated from here: __ctor!(immutable(A))
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(618):
instantiated from here: _send!(immutable(A))
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(594):
instantiated from here: _send!(immutable(A))
Is this is a bug?
On a related note - sometimes when sending a shared struct I get a
compilation error similar to this:
/opt/dmd2/linux/bin64/../../src/phobos/std/variant.d(638): Error: function
core.stdc.string.memcpy (void* s1, const(void*) s2, ulong n) is not callable
using argument types (ubyte[32]*, shared(Notification)*, ulong)
/opt/dmd2/linux/bin64/../../src/phobos/std/variant.d(580): Error: template
instance std.variant.VariantN!32LU.VariantN.opAssign!(shared(Notification))
error instantiating
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(117):
instantiated from here: __ctor!(shared(Notification))
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(628):
instantiated from here: __ctor!(shared(Notification))
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(618):
instantiated from here: _send!(shared(Notification))
/opt/dmd2/linux/bin64/../../src/phobos/std/concurrency.d(594):
instantiated from here: _send!(shared(Notification))
If I then add more fields to the struct (eg. dummy "string a,b") it compiles
fine.
Is this another bug or am I missing something?
--
Marek Janukowicz
More information about the Digitalmars-d-learn
mailing list