Structs can't be zero bytes in size?

Lionello Lunesu lionello at lunesu.remove.com
Wed Sep 4 07:09:09 PDT 2013


On 9/3/13 10:59, Andrej Mitrovic wrote:
> On 9/3/13, Lionello Lunesu <lionello at lunesu.remove.com> wrote:
>> struct Z {};
>> Z a, b;
>> assert(&a != &b);
>
> Since the structs are declared empty, their 1-byte values don't
> matter. So their addresses don't really matter either.
>

It has to do with the ol' 'identity vs equality'. In the example above, 
a and b are not identical ("do not refer to the same thing") and so 
their addresses should not be equal.

The address of two 'named things' is the same if-and-only-if the names 
refer to the same thing.

L.


More information about the Digitalmars-d mailing list