[Python-Dev] ANSI strict aliasing and Python

Martin v. L÷wis martin@v.loewis.de
19 Jul 2003 13:09:46 +0200


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

# All pointers to structure types shall have the same representation
# and alignment requirements as each other.

So all pointers are equal.

Regards,
Martin