Template error with gdc-10 but not with latest dmd and ldc

Per Nordlöw per.nordlow at gmail.com
Sun Jul 26 19:04:11 UTC 2020


The code example


long add_long_n0(alias T=void)(long x) @safe pure nothrow @nogc { 
return x + 0; }

int main(string[] args)
{
     long long_sum = 0;
     long_sum += add_long_n0!(void)(cast(long)0);
     return cast(int)long_sum;
}


compiles without errors with dmd and ldc. But with gdc-10 as

     gdc -c linear_t.d

it errors as

linear_t.d:6:17: error: template instance add_long_n0!() does not 
match template declaration add_long_n0(alias T = void)(long x)
     6 |     long_sum += add_long_n0!()(cast(long)0);
       |                 ^


Why can't LDC handle such a trivial template example?


More information about the Digitalmars-d-learn mailing list