pointer <-> integer conversion warnings (bogus -Wall warnings)

Tom Lord lord@emf.net
Wed Mar 13 16:26:00 GMT 2002


   From: Richard Henderson <rth@redhat.com>

   No, that's what C99's intptr_t is for.  But as it happens, I've
   never seen a system for which size_t was not the correct size
   [for integer -> pointer conversion]

   and

	x = (int)(size_t) p;

That double cast is not safe.

The simple rule that explicit casts to appropriate types don't
generate warnings in the absense of extraordinary options gives this
class of warnings a clear and useful relation to the various
standards.  I don't understand why that rule is at all controversial.

-t



More information about the Gcc mailing list