This is the mail archive of the
mailing list for the GCC project.
Re: 3.0.1 Freeze
- To: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Subject: Re: 3.0.1 Freeze
- From: Mark Mitchell <mark at codesourcery dot com>
- Date: Tue, 07 Aug 2001 12:52:28 -0700
- cc: "gcc at gcc dot gnu dot org" <gcc at gcc dot gnu dot org>
> #define PTRRELOC(x) ((typeof(x))((unsigned long)(x) + offset))
> #define RELOC(x) (*PTRRELOC(&(x)))
> offset = get_reloc_offfset();
> strcpy(dest, RELOC("test"));
> I don't see anything illegal/undefined/unportable about that code, just
> plain C pointer arithmetic to implement a poor mans relocation in early
> boot code.
Ah. So, ignoring the non-standard `typeof', you have cast a pointer to
an integer, added another integer, and cast back to a pointer. That
is (I checked) implementation-defined behavior, but the sensible
definition is that it do what you think.
So, I am now convinced that this optimization is too aggressive. I
will simply remove it.
Mark Mitchell firstname.lastname@example.org
CodeSourcery, LLC http://www.codesourcery.com