Zero-length static array spec
FG via Digitalmars-d
digitalmars-d at puremagic.com
Sat Feb 7 05:43:57 PST 2015
On 2015-02-07 at 13:21, Iain Buclaw via Digitalmars-d wrote:
>>
>> foo(&p.data) // fine, ubyte*
>
> This is OK - gets passed as ubyte*
>
>> bar(p.data[i]) // fine, ubyte (or memory violation)
>
> This is OK - gets passed as ubyte - though will throw arrayBounds
> error unless -noboundschecks.
>
>> xxx(p.data) // ERROR, makes no sense, shouldn't compile
>
> This is OK - gets passed as ubyte[] - the dynamic array will have a
> length of '0' and the ptr to &p.data.
Oh, I see. That is quite a nice solution. Better than compilation error.
More information about the Digitalmars-d
mailing list