This is the mail archive of the gcc-bugs@gcc.gnu.org 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]

[Bug c/54037] New: Warn pointer to integer cast for ilp32


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.


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