On Mon, Jan 13, 2014 at 05:32:26PM +0100, Marek Polacek wrote:
> This doesn't really fix the PR, but solves a related issue, where we
> have e.g.
> struct U {};
> static struct U b[6];
> 
> int foo (struct U *p, struct U *q)
> {
>   return q - p;
> }
> int main()
> {
>   return foo (&b[0], &b[4]);
> }
> Such a program SIGFPEs at runtime.  But subtraction of pointers to empty
> structures/unions doesn't really make sense and this patch forbids that.
> Note that GCC permits a structure/union to have no members, but it's only
> an extension, in C11 it's undefined behavior.
> 
> Regtested/bootstrapped on x86_64, ok for trunk?

The patch will need some tweaking, I realized that e.g. for struct S {
union {}; }; it doesn't do the right thing...

        Marek

Reply via email to