This is the mail archive of the
mailing list for the GCC project.
Re: [patch] for PR 18040
- From: kenner at vlsi1 dot ultra dot nyu dot edu (Richard Kenner)
- To: zack at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Sun, 17 Oct 04 22:33:20 EDT
- Subject: Re: [patch] for PR 18040
It only makes any sense at all if I assume you meant to write 'var'
instead of 'foo' in both places inside the body of the function.
Also, you left out the declaration of uc, which meant I had to go look
up how unchecked_conversion works.
I wrote it at one point, but apparently edited it out. I actually
can't write Ada very well.
return ((r *) &var)->f1 + var;
As I said earlier, that works *in this case*, but not in the general
case of nested field references, because you might be needing to take
the address of something non-addressable and ...
This does not look very different from what you are generating now,
but sandwiching the cast inside an address-of and dereference means
that the gimplifier can break it down without needing to create an
aggregate temporary, producing something like this:
But you *would* need the aggerate temporary in the nested reference case,
which is the general case. I don't see a strong argument for doing
something special for the degenerate case here.
The only catch is that alias analysis must understand that rp aliases
var. This may require some adjustment to GNAT's alias set logic.
If it did, then it couldn't be done because the types and the unchecked
conversion could be in different translation units, so you can't know
the unchecked conversion existed when you were assigning alias sets
to the types.
This stuff is *very* tricky and, as I said, we've been throught it before.