This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: aliasing problem with va_arg
- To: wilson at cygnus dot com
- Subject: Re: aliasing problem with va_arg
- From: Mark Mitchell <mark at markmitchell dot com>
- Date: Wed, 28 Oct 1998 18:06:44 -0800
- CC: egcs at cygnus dot com, wilson at cygnus dot com
- References: <199810282359.PAA27947@rtl.cygnus.com>
- Reply-to: mark at markmitchell dot com
>>>>> "Jim" == Jim Wilson <wilson@cygnus.com> writes:
Jim> I finally got a chance to take a better look at the problem,
Jim> and I noticed that your aliasing code allows type punning if
Jim> it sees a direct union member reference. However, it does
Right. All uses of type-punning are implementation-defined; I defined
them in the manual to not work except for the one explict case you
mention here.
In general, things can get arbitrarily complicated: you can take the
address of things in the union and then pun through them, etc. I
don't see any reason to make this work, especially since it will
completely trash type-based alias analysis.
Your patch is probably OK. I am leery, though, of trying to extend
things too far, though; much better that people learn not to use
type-punning. It's not safe, and it's not portable. I understand
that you want to do this to fix the va-sparc.h problem, and I'm
sympathetic.
I still think the right thing to do is really to do __builtin_va_arg
and friends; this might be a bit of work, but if you cannot find the
time, perhaps some other interested party can do the work, or arrange
for it to be done. As you point out, it would be nice to allow alias
analysis in varargs functions; this will require (at least) also
fixing the HP macros. Your fix will fix the SPARC problem, and that
may be the best thing to do for now, but it is not a long-term
solution.
--
Mark Mitchell mark@markmitchell.com
Mark Mitchell Consulting http://www.markmitchell.com