Thread overview
[Issue 16542] makeArray not usable with const initializer
Sep 25, 2016
Ryan
Jan 10, 2017
b2.temp@gmx.com
Jan 10, 2017
Ryan
Mar 21, 2020
Basile-z
September 25, 2016
https://issues.dlang.org/show_bug.cgi?id=16542

Ryan <clumsycodemonkey@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |clumsycodemonkey@gmail.com

--
December 15, 2016
https://issues.dlang.org/show_bug.cgi?id=16542

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrei@erdani.com
           Assignee|nobody@puremagic.com        |lucia.mcojocaru@gmail.com

--
January 04, 2017
https://issues.dlang.org/show_bug.cgi?id=16542

Andrei Alexandrescu <andrei@erdani.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED

--
January 10, 2017
https://issues.dlang.org/show_bug.cgi?id=16542

b2.temp@gmx.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |b2.temp@gmx.com

--- Comment #1 from b2.temp@gmx.com ---
Can you add a test case please ? I suspect this report to be either either bad formulated or invalid because with DMD 2.073-b1 the following test passes:

unittest
{
    const int[] v;
    void test(T)(in T t)
    {
        auto a = theAllocator.makeArray(100, t);
    }
    test(v);
}

--
January 10, 2017
https://issues.dlang.org/show_bug.cgi?id=16542

--- Comment #2 from Ryan <clumsycodemonkey@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,

--
October 30, 2017
https://issues.dlang.org/show_bug.cgi?id=16542

--- Comment #3 from github-bugzilla@puremagic.com ---
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/cd66c0cba650d63785ccb79a115964e6472692ca fix issue 16542

https://github.com/dlang/phobos/commit/2e9271962ffbe2cdabff8fe39be3c55121de6232 Merge pull request #5028 from somzzz/issue_16542

fix issue 16542 -  makeArray not usable with const initializer

--
October 30, 2017
https://issues.dlang.org/show_bug.cgi?id=16542

github-bugzilla@puremagic.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|---                         |FIXED

--
December 18, 2017
https://issues.dlang.org/show_bug.cgi?id=16542

--- Comment #4 from github-bugzilla@puremagic.com ---
Commits pushed to stable at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/cd66c0cba650d63785ccb79a115964e6472692ca fix issue 16542

https://github.com/dlang/phobos/commit/2e9271962ffbe2cdabff8fe39be3c55121de6232 Merge pull request #5028 from somzzz/issue_16542

--
March 21, 2020
https://issues.dlang.org/show_bug.cgi?id=16542

Basile-z <b2.temp@gmx.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|b2.temp@gmx.com             |

--