Bug 10847 – uninitializedArray accepts arguments which make it fail internally
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-08-18T17:14:00Z
Last change time
2015-06-09T05:14:49Z
Assigned to
nobody
Creator
andrej.mitrovich
Comments
Comment #0 by andrej.mitrovich — 2013-08-18T17:14:13Z
-----
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.
Comment #1 by monarchdodra — 2013-08-18T23:32:20Z
(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)"
Comment #2 by andrej.mitrovich — 2013-10-23T17:19:18Z