Sub-optimal code generated for certain calls to functions with auto ref qualified parameters

Per Nordlöw per.nordlow at gmail.com
Mon Aug 10 14:31:05 UTC 2020


On Monday, 10 August 2020 at 11:24:36 UTC, Per Nordlöw wrote:
> T square_t(T)(const auto ref scope T x)
> {
>     return x*x;
> }

Same difference in generated code for `square_nt` and `square_t` 
for

T square_nt(T)(immutable scope T x)
{
     return x*x;
}

T square_t(T)(immutable auto ref scope T x)
{
     return x*x;
}

@safe pure nothrow @nogc unittest
{
     immutable long x;
     auto y = square_nt(x);
     auto z = square_t(x);
}


More information about the Digitalmars-d mailing list