More damage to intuition (was RE: [Python-Dev] Comparison of recursive objects)

Tim Peters
Sun, 21 Jan 2001 20:11:52 -0500

[Greg Ewing]
> I'm not sure that the proposed alternative (casting both
> pointers to ints and comparing the ints) is any better.
> Does the C std define the result of doing that to two
> unrelated pointers?

C99 guarantees that, if the type exists, casting a pointer to type uintptr_t
won't blow up, and also guarantees that comparisons between (at least) ints
of the same type won't blow up.  Beyond that, we don't care what it returns.
Mostly we're trying to eliminate warnings Barry has to wade thru from
Insure++ -- same reason we have a "no compiler warnings!" build policy.
Doing the cast is obviously "better" when viewed through Barry's 4AM eyes.

You can find out *why* C has this rule (which was in C89, not new in C99) by
reading the C FAQ.