[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
Fri Jan 26 19:18:00 GMT 2018


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

--- Comment #3 from Martin Uecker <uecker at eecs dot berkeley.edu> ---


(In reply to Richard Biener from comment #1)
> Confirmed.  I think the C language doesn't specify this since zero-sized
> arrays are a GNU extension and thus in C no zero-sized types/decls exist?
> 
> So not sure if there's anything to fix - Joseph?
> 
> Note that for global unique addresses you can use global objects of size 1,
> like a char object.  Not sure why you think using a GNU extension is
> superior?

It makes it clear in a nice way that these variables are not used to store
information.


(In reply to Jakub Jelinek from comment #2)
> Zero sized objects of course can have the same address and always had.
> Just in your testcase the comparison used to be optimized away before
> r218462.
> If you hide it from the optimizers, like with:
> 	int *p = a;
> 	int *q = b;
> 	asm ("" : "+r" (p), "+r" (q));
>         if(p == q) __builtin_abort ();
> you'll get aborts all the way to r104500 (oldest revision I have around).

Oh well, so this was simply an incorrect optimization.


More information about the Gcc-bugs mailing list