This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Allow 64bit warnings on 32bit targets

On Fri, 19 Dec 2003, Andi Kleen wrote:

> gcc gives some warnings ("cast from pointer to integer of different
> size" etc.) only with 64bit targets. This patch adds a new flag
> -W64bit to enable them for 32bit targets too. This is useful to do a
> quick check if the code is 64bit clean even when you are compiling for
> 32bit. 

The documentation doesn't adequately explain what warnings it does give,
and the patch needs a testcase to cover both what it is meant to warn for
and what it isn't meant to warn for.

Casting to intptr_t or uintptr_t is guaranteed safe and clearly shouldn't
warn, and in practice much code may cast to size_t or ptrdiff_t as well,
which should be safe on most systems.  But these types may get defined to
int on 32-bit systems, while you need to distinguish them from casts to
plain int or unsigned int (which should get warnings).  Checking whether a
typedef with one of those names is used would be rather a kludge, but
might be adequate, and in general you can't tell whether someone has
autoconfed a type to be safe for this or not.

Joseph S. Myers

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]