Hi,
The PR that replaces the _d_arrayctor
and _d_arraysetctor
hooks was blocked
by a bug in the compiler's backend, which was posted as an issue here. The issue was eventually fixed, which has allowed the aforementioned PR to make some progress.
However, another bug was revealed, whereby the _d_arrayctor
template function turned out to be incorrect. When instantiating the function with const
or immutable
array type as argument, the compiler issued warnings when its return value was ignored, because _d_arrayctor
is also a strongly pure function. This means that the call to it seemingly has no effect. Furthermore, this false impression might make the compiler remove the call to it altogether.
A temporary and hackish solution was to add a pointer type parameter to _d_arrayctor
, implemented by this PR. This solution turns _d_arrayctor
from being strongly pure to being weakly pure. As a result, its call cannot be optimised out by the compiler.
We're still looking for a more elegant solution to the issue above, as discussed in this thread. One alternative is to change _d_arrayctor
's signature so that its 2 parameters are of different types - say T1[]
and T2[]
- so that Unqual!T1 == Unqual!T2
. I am currently working on this change.
In the meantime, I improved the error messages for the _d_arrayctor
and _d_arraysetctor
templates in druntime. For an older PR, I had to resort to using some rather austere error messages because of the requirement that _d_arrayctor
be @nogc
.
However, following my mentor Edi's advice, I implemented @nogc
versions of the array utils functions inside core/internal/util/array.d
and updated _d_arrayctor
to use enforceRawArraysConformableNogc
, in this PR.
Thanks,
Teodor