This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: strict aliasing: how to swap pointers
- From: Andrew Haley <aph at redhat dot com>
- To: Matthew Woehlke <mw_triad at users dot sourceforge dot net>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Sat, 03 May 2008 10:09:50 +0100
- Subject: Re: strict aliasing: how to swap pointers
- References: <481785A7.3060506@mit.edu> <00b701c8aa51$ef2c9b50$cd85d1f0$@net> <4817B98A.7090705@mit.edu> <4818340F.1080100@redhat.com> <4818746C.5040106@mit.edu> <4818857A.9090201@redhat.com> <fvgci7$je0$1@ger.gmane.org>
Matthew Woehlke wrote:
> Andrew Haley wrote:
>> Consider an arch which has pointers to char (and void *) that are two
>> words
>> in size, and pointers to int that are one word in size. On such an arch
>> your exchange() function won't work, which is one reason why you need
>> a macro
>> to do it in Standard C.
>
> What platforms are there where sizeof(T*) != sizeof(void*) for some T?
I'm not sure: certainly nothing gcc supports, because gcc internally uses
Pmode for all pointers. DEC-10 possibly, maybe others. And of course, some
segmented architectures have pointers of different sizes.
Andrew.