This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/54037] New: Warn pointer to integer cast for ilp32
- From: "hjl.tools at gmail dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 19 Jul 2012 21:02:29 +0000
- Subject: [Bug c/54037] New: Warn pointer to integer cast for ilp32
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54037
Bug #: 54037
Summary: Warn pointer to integer cast for ilp32
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hjl.tools@gmail.com
On Linux/x86-64,
[hjl@gnu-6 tmp]$ cat x.c
unsigned long long
foo (void *p)
{
return (long) p;
}
[hjl@gnu-6 tmp]$
and
[hjl@gnu-6 tmp]$ cat y.c
unsigned long long
foo (void *p)
{
return (unsigned long) p;
}
[hjl@gnu-6 tmp]$
generate the same code with gcc -m64 since size of long == size of
long long. However, they are different with "gcc -mx32" and x.c may
be incorrect. It is desirable to issue a warning when casting from
pointer to signed integer and then to unsigned integer of different
size.