Lowerings to strongly pure _d_arrayctor trigger warnings or risk being incorrectly removed
RazvanN
razvan.nitu1305 at gmail.com
Thu Oct 14 09:22:09 UTC 2021
On Tuesday, 12 October 2021 at 16:46:10 UTC, Johan wrote:
> On Tuesday, 12 October 2021 at 16:27:51 UTC, Teodor Dutu wrote:
>> Hi,
>>
>> I've been working on [this
>> PR](https://github.com/dlang/dmd/pull/13116) for a while now
>> and after seeing it fail some tests in phobos (for example,
>> [this
>> one](https://cirrus-ci.com/task/5609501660282880?logs=test_phobos#L116)), my mentors for SAoC 2021, Razvan Nitu and Eduard Staniloiu, and I figured out that, when lowered using `const` or `immutable` arguments, `_d_arrayctor` becomes a strongly pure function.
>
> Why would you want to instantiate `_d_arrayctor` multiple times
> for different constness of its arguments?
> You can choose the exact details of the lowering, so would your
> problem not be solved by simply lower to calls without
> const/immutable parameter types?
>
> -Johan
Because you want to call the correct copy constructor. Consider:
struct S
{
this(ref S rhs) immutable {}
}
void main()
{
S[2] a;
immutable S[2] b = a;
}
More information about the Digitalmars-d
mailing list