https://issues.dlang.org/show_bug.cgi?id=16542

--- Comment #2 from Ryan <clumsycodemon...@gmail.com> ---
The code below compiles and runs unless you uncomment the first case. Then it
fails on DMD 2.72.2 on mac. I ran this file with 'rdmd -unittest -main test.d'.

It fails to find a template match for the first case, but when you cast away
the const, it works fine.
-------------------------------------------
module test;

void doSomething(T)(in T initialValue)
{
  import std.experimental.allocator;
  import std.stdio;

  pragma(msg, typeof(initialValue).stringof ~ "  " ~
typeof(cast()initialValue).stringof);

  //T[] t = theAllocator.makeArray!T(5, initialValue); // won't compile

  T[] t2 = theAllocator.makeArray!T(5, cast()initialValue); // this one
compiles

  // ... use t and t2
  writeln(t2);
}

unittest
{
    int i = 5;
    int[3] j = [1,2,3];

    doSomething(i);
    doSomething(j);
}
------------------------------------------------

Thanks,

--

Reply via email to