[Python-Dev] ANSI strict aliasing and Python

Ben Laurie ben@algroup.co.uk
Sat, 19 Jul 2003 14:07:14 +0100


Martin v. Löwis wrote:

> Ben Laurie <ben@algroup.co.uk> writes:
> 
> 
>>>So if you convert two pointers to the same PyIntObject to PyObject*,
>>>and convert them back, then compare them, you are guaranteed to get
>>>true. If you compare them while they are PyObject*, no guarantees are
>>>given.
>>
>>FWIW, K&R 2nd Ed. says in A6.6 that this is only true if the conversion
>>is to a type whose alignment requirement is less or equally strict.
> 
> 
> What is "this" in your message? "no guarantees are given", or "you are
> guaranteed to get true". If the latter: Sure, but 6.2.5p26 says

Sorry, "this" is the conversion to some other pointer type and back
yielding the same value.

> # All pointers to structure types shall have the same representation
> # and alignment requirements as each other.
> 
> So all pointers are equal.

All pointers to structures, sure.

Cheers,

Ben.

-- 
http://www.apache-ssl.org/ben.html       http://www.thebunker.net/

"There is no limit to what a man can do or how far he can go if he
doesn't mind who gets the credit." - Robert Woodruff