[Bug c/84046] [6/7/8 Regression] global zero-sized objects may have same address

uecker at eecs dot berkeley.edu gcc-bugzilla@gcc.gnu.org
Sat Jan 27 09:02:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=84046

--- Comment #5 from Martin Uecker <uecker at eecs dot berkeley.edu> ---
(In reply to Jakub Jelinek from comment #4)
> If you want aggregate with size 1 and isn't used to store information, use
> typedef struct { char : 1; } zero;
> instead.

Yes, thank you.

But for my understanding: Is there a reason why it is important that zero-sized
objects should sometimes have the same address? I am wondering because I think
zero-sized arrays would make sense to allow in C (it sometimes makes
programming edge cases simpler in numerical code) and at the same time I think
it might be a nice principle to require that all unique objects existing at the
same time should also have a unique address.


More information about the Gcc-bugs mailing list