Re: strict aliasing: how to swap pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



John Love-Jensen wrote:
void** is not void*.

Ah, of course. So with strict aliasing, GCC assumes that a void** pointer only points to variables of exactly type void*? This would explain my confusion. I was assuming that since T* is convertible to void*, void** can point to any T*. It makes sense that this is not true.

I wish I could get GCC to generate a "surprising" optimization for a void**/T** type pun, but I have been unable to do so. This, of course, doesn't mean that ignoring the warning is safe.

It seems to me that the lesson for me is that when doing low-level type-unsafe manipulation, void* pointers should be used. Since GCC must assume that void* pointers can point anywhere, it will not be able to optimize away the accesses to them, which is what I want in this case. Please correct me if I am wrong about this.

Thanks,

Evan

--
Evan Jones
http://evanjones.ca/

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux