This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Possible problem wiht nonoverlapping_component_refs_p

On Wed, Dec 05, 2001 at 09:47:07PM -0500, Richard Kenner wrote:
> struct T1 {int a, b; };
> struct T2 {struct T1 x; };
> struct T3 {int x; struct T1 y; };
> union uu {struct T2 t2; struct T3 t3; } u;
> Now consider uu.t2.x.b and uu.t3.y.a.
> These two overlap in memory, but, as I understand that routine, we'll return
> that they don't overlap because they are the same field in the same structure.
> Am I missing something?

Hmm, that does appear broken.  I'd convinced myself that the language
didn't allow two live objects to overlap.  Technically, the language
doesn't.  But unions are one place that GCC has promised that this sort
of thing would work.

Now, we did only promise that this would work when accessed directly
through the union, so we don't have to worry about

	struct T1 *t1_1 = &u.t2.x;
	struct T1 *t1_2 = &u.t2.y;
	t1_1->b vs t1_2->a

So if we do have offset data all the way up the chain (which we should),
then we should be able to handle this as with your overlapping fields, no?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]