[Issue 22723] Cannot allocate a slice on heap

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Feb 1 21:20:22 UTC 2022


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

moonlightsentinel at disroot.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |moonlightsentinel at disroot.o
                   |                            |rg
           Severity|major                       |normal

--- Comment #1 from moonlightsentinel at disroot.org ---
Allocating slices by themselves is explicitly disallowed due to the ambiguitee
possibilitly IIUC (you almost always want to allocate the actual array).
run.dlang.io shows the degradation of the error message:

Up to      2.078.1: Failure with output: onlineapp.d(3): Error: new can only
create structs, dynamic arrays or class objects, not ubyte[]'s
2.079.1 to 2.090.1: Failure with output: onlineapp.d(3): Error: new can only
create structs, dynamic arrays or class objects, not `ubyte[]`'s
2.091.1 to 2.093.1: Failure with output: onlineapp.d(3): Error: cannot create a
`ubyte[]` with `new`
Since      2.094.1: Failure with output: onlineapp.d(3): Error: missing length
argument for array

The error message probably complain about the type + suggest adding a length
(which should be the solution in most cases)

--


More information about the Digitalmars-d-bugs mailing list