Zero-length static array spec
Daniel Murphy via Digitalmars-d
digitalmars-d at puremagic.com
Fri Feb 6 09:58:21 PST 2015
"David Nadlinger" wrote in message
news:actxhygoikohznovzbcl at forum.dlang.org...
> Let's have a look at a related example:
>
> int[0] data0;
> int[0] data1;
>
> assert(data0.ptr != data1.ptr); // ???
>
> If you want this assert to succeed, how do you ensure that the addresses
> are different without allocating at least one byte of stack space (which
> currently seems to be prohibited by the "does not take up space" clause).
I seriously doubt the intent of that line in the spec was meant to apply to
stack-allocated zero length static arrays. I think we should just change it
so that we are allowed to allocate some non-zero amount of stack space for
the array and give it a valid pointer. Layout matters when used in a
struct, not so much when it's on the stack.
More information about the Digitalmars-d
mailing list