Zero-length static array spec
H. S. Teoh via Digitalmars-d
digitalmars-d at puremagic.com
Sun Feb 1 07:50:08 PST 2015
On Sun, Feb 01, 2015 at 03:46:15PM +0000, ketmar via Digitalmars-d wrote:
> 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. ;-)
Actually, it *can* be null too, since it doesn't actually take up any
space, so it would fit perfectly fine in nullspace (non-existent space)
as well. :-P
T
--
IBM = I'll Buy Microsoft!
More information about the Digitalmars-d
mailing list