Zero-length static array spec

ketmar via Digitalmars-d digitalmars-d at puremagic.com
Sun Feb 1 07:46:15 PST 2015


On Sun, 01 Feb 2015 15:34:39 +0000, Iain Buclaw via Digitalmars-d wrote:

> Regardless of size, a static array should always have an address on the
> stack.  Of course, dereferencing said address is undefined.
> 
> You can also consider it a require that although a zero-length static
> array may have an address, it doesn't take up any space either.
> 
> Consider:
> 
> int[0] data0;
> int[1] data1;
> 
> 
> Here, you could expect both data0 and data1 to have the same .ptr
> address, but data0.ptr == data1.ptr should not succeed either.

actually, `data0.ptr` can point anywhere (except 0 as null ;-), 'cause 
it's so small that it takes no room at all, so it doesn't matter where it 
will be placed. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20150201/8ba4ee6f/attachment.sig>


More information about the Digitalmars-d mailing list