16431, “mppf”, “copy elision for domains interaction with array-domain relationship”, “2020-09-22T14:38:38Z”
The language is defined to have the same copy elision semantics for domains as for other types. However that is not yet implemented (because chpl__coerceMove for domains always does default-init/assign).
However if we start to enable this copy elision we run into a semantic question reflecting conflicting goals between the copy elision and the way that arrays have a relationship with their domain.
For example, consider this program:
var D = {1..10};
var A:[D] int;
// Now changing `D` will change `A.domain` and reallocate the element storage
var DD = D; // If D is not used again, copy elision rule says this is move initialization
var AA:[DD] int;
DD = {1..3};
// This should change `AA.domain` for sure.
// But, what should happen with `A.domain` ?
Note that this case is related to a case with initializers:
record R {
var DDD: domain(1);
var AAA: [DDD] int;
}
{
var r = new R({1..10});
// The above call creates a temporary domain DDD_in and a temporary array AAA_in
// over that domain. But, we want the relationship between the domain and the array
// to be preserved both in the case of a user-provided initializer with `in` intents
// and with the compiler-generated one.
r.DDD = {1..3};
writeln(r.AAA); // should print 3 elements
}
In particular, if the initializer for record R tries to move initialize from DDD_in or AAA_in it should not break the relationship between these two.