This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Possible problem wiht nonoverlapping_component_refs_p
- From: Richard Henderson <rth at redhat dot com>
- To: Richard Kenner <kenner at vlsi1 dot ultra dot nyu dot edu>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 5 Dec 2001 22:24:07 -0800
- Subject: Re: Possible problem wiht nonoverlapping_component_refs_p
- References: <10112060247.AA27449@vlsi1.ultra.nyu.edu>
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?
r~