Thread overview
[Issue 10847] New: uninitializedArray accepts arguments which make it fail internally
Aug 19, 2013
Andrej Mitrovic
Oct 24, 2013
Andrej Mitrovic
August 19, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10847

           Summary: uninitializedArray accepts arguments which make it
                    fail internally
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: andrej.mitrovich@gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-08-18 17:14:13 PDT ---
-----
import std.array;

void main()
{
    ubyte[] source = uninitializedArray!(ubyte[])(ulong.init);
}
-----

$ dmd test.d

C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\array.d(321): Error: function
core.memory.GC.malloc (uint sz, uint ba = 0u) is not callable using argument
types (ulong, BlkAttr)
C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\array.d(272): Error: template
instance std.array.arrayAllocImpl!(false, ubyte[], ulong) error instantiating
test.d(7):        instantiated from here: uninitializedArray!(ubyte[], ulong)
test.d(7): Error: template instance std.array.uninitializedArray!(ubyte[],
ulong) error instantiating

The constraint should disallow the argument instead of failing inside of Phobos when instantiating other templates.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
August 19, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10847


monarchdodra@gmail.com changed:

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


--- Comment #1 from monarchdodra@gmail.com 2013-08-18 23:32:20 PDT ---
(In reply to comment #0)
> -----
> import std.array;
> 
> void main()
> {
>     ubyte[] source = uninitializedArray!(ubyte[])(ulong.init);
> }
> -----
> 
> $ dmd test.d
> 
> C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\array.d(321): Error: function
> core.memory.GC.malloc (uint sz, uint ba = 0u) is not callable using argument
> types (ulong, BlkAttr)
> C:\DMD\dmd2\windows\bin\..\..\src\phobos\std\array.d(272): Error: template
> instance std.array.arrayAllocImpl!(false, ubyte[], ulong) error instantiating
> test.d(7):        instantiated from here: uninitializedArray!(ubyte[], ulong)
> test.d(7): Error: template instance std.array.uninitializedArray!(ubyte[],
> ulong) error instantiating
> 
> The constraint should disallow the argument instead of failing inside of Phobos when instantiating other templates.

This was specifically fixed in my "Rewrite [Un|Minimally]InitializedArray". https://github.com/D-Programming-Language/phobos/pull/1447

Specifically, it will static assert with the message:
"Argument types in (ulong) are not all convertible to size_t: (ulong)"

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
October 24, 2013
http://d.puremagic.com/issues/show_bug.cgi?id=10847



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2013-10-23 17:19:18 PDT ---
https://github.com/D-Programming-Language/phobos/pull/1498

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------