On Fri, 26 Apr 2007, Geoffrey Keating wrote:

> This seems reasonable to me, but maybe it would be simpler to write
> 
> If there are one or more incomplete structure or union types which
> cannot all be completed without producing undefined behaviour, the
> behaviour is undefined.
> 
> if that gives the same effect (which I think it does)?

That suffers somewhat from the vagueness that afflicts this area (what 
rearrangements of translation units are permitted in completing the 
types?).  I considered some other examples and decided that what I wanted 
was unifiability even in some cases that don't involve incomplete types.  
For example:

// TU 1
void
f (void)
{
  struct s { int a; };
  extern struct s a, b;
}

void
g (void)
{
  struct s { int a; };
  extern struct s c, d;
}

// TU 2
void
h (void)
{
  struct s { int a; };
  extern struct s a, c;
}

void
i (void)
{
  struct s { int a; };
  extern struct s b, d;
}


Here, each object individually has compatible types in the two translation 
units - but "a" and "b" have compatible complete types within TU 1, but 
incompatible complete types withing TU 2.

I didn't feel it should be necessary to unify two incompatible types from 
the same translation unit (even if they'd be compatible in different 
translation units), nor to split the uses of a single type within a 
translation unit into two or more distinct and incompatible types.

-- 
Joseph S. Myers
[EMAIL PROTECTED]

Reply via email to