public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/54037] New: Warn pointer to integer cast for ilp32
@ 2012-07-19 21:02 hjl.tools at gmail dot com
2012-07-19 21:50 ` [Bug c/54037] Warn pointer to signed " hjl.tools at gmail dot com
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2012-07-19 21:02 UTC (permalink / raw)
To: gcc-bugs
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.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/54037] Warn pointer to signed integer cast for ilp32
2012-07-19 21:02 [Bug c/54037] New: Warn pointer to integer cast for ilp32 hjl.tools at gmail dot com
@ 2012-07-19 21:50 ` hjl.tools at gmail dot com
2012-07-19 21:55 ` pinskia at gcc dot gnu.org
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2012-07-19 21:50 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54037
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> 2012-07-19 21:50:33 UTC ---
Created attachment 27836
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=27836
A patch to add -Wpointer-to-signed-int-cast
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/54037] Warn pointer to signed integer cast for ilp32
2012-07-19 21:02 [Bug c/54037] New: Warn pointer to integer cast for ilp32 hjl.tools at gmail dot com
2012-07-19 21:50 ` [Bug c/54037] Warn pointer to signed " hjl.tools at gmail dot com
@ 2012-07-19 21:55 ` pinskia at gcc dot gnu.org
2012-07-19 22:04 ` hjl.tools at gmail dot com
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-07-19 21:55 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54037
--- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-07-19 21:55:24 UTC ---
(In reply to comment #1)
> Created attachment 27836 [details]
> A patch to add -Wpointer-to-signed-int-cast
This won't work for intptr_t which is a signed integer type.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/54037] Warn pointer to signed integer cast for ilp32
2012-07-19 21:02 [Bug c/54037] New: Warn pointer to integer cast for ilp32 hjl.tools at gmail dot com
2012-07-19 21:50 ` [Bug c/54037] Warn pointer to signed " hjl.tools at gmail dot com
2012-07-19 21:55 ` pinskia at gcc dot gnu.org
@ 2012-07-19 22:04 ` hjl.tools at gmail dot com
2012-07-19 23:45 ` pinskia at gcc dot gnu.org
2012-08-14 18:04 ` hjl.tools at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2012-07-19 22:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54037
--- Comment #3 from H.J. Lu <hjl.tools at gmail dot com> 2012-07-19 22:04:39 UTC ---
(In reply to comment #2)
> (In reply to comment #1)
> > Created attachment 27836 [details]
> > A patch to add -Wpointer-to-signed-int-cast
>
> This won't work for intptr_t which is a signed integer type.
-Wpointer-to-signed-int-cast will issue a warning for
[hjl@gnu-6 pr54037]$ cat foo.c
#include <stdint.h>
unsigned long long
foo (void *p)
{
return (intptr_t) p;
}
[hjl@gnu-6 pr54037]$
-Wpointer-to-signed-int-cast is used to help catch the potential
point to signed integer cast issue. It shouldn't be turned on
by default.
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/54037] Warn pointer to signed integer cast for ilp32
2012-07-19 21:02 [Bug c/54037] New: Warn pointer to integer cast for ilp32 hjl.tools at gmail dot com
` (2 preceding siblings ...)
2012-07-19 22:04 ` hjl.tools at gmail dot com
@ 2012-07-19 23:45 ` pinskia at gcc dot gnu.org
2012-08-14 18:04 ` hjl.tools at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu.org @ 2012-07-19 23:45 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54037
--- Comment #4 from Andrew Pinski <pinskia at gcc dot gnu.org> 2012-07-19 23:44:59 UTC ---
We have this request a while back and it was rejected for the same reason why I
said it won't work for intptr_t (though I cannot find the discussion).
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Bug c/54037] Warn pointer to signed integer cast for ilp32
2012-07-19 21:02 [Bug c/54037] New: Warn pointer to integer cast for ilp32 hjl.tools at gmail dot com
` (3 preceding siblings ...)
2012-07-19 23:45 ` pinskia at gcc dot gnu.org
@ 2012-08-14 18:04 ` hjl.tools at gmail dot com
4 siblings, 0 replies; 6+ messages in thread
From: hjl.tools at gmail dot com @ 2012-08-14 18:04 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54037
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Attachment #27836|0 |1
is obsolete| |
--- Comment #5 from H.J. Lu <hjl.tools at gmail dot com> 2012-08-14 18:04:35 UTC ---
Created attachment 28016
--> http://gcc.gnu.org/bugzilla/attachment.cgi?id=28016
A patch to add -Wpointer-to-signed-int-cast
This patch only warns when ptr_mode != word_mode.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2012-08-14 18:04 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-19 21:02 [Bug c/54037] New: Warn pointer to integer cast for ilp32 hjl.tools at gmail dot com
2012-07-19 21:50 ` [Bug c/54037] Warn pointer to signed " hjl.tools at gmail dot com
2012-07-19 21:55 ` pinskia at gcc dot gnu.org
2012-07-19 22:04 ` hjl.tools at gmail dot com
2012-07-19 23:45 ` pinskia at gcc dot gnu.org
2012-08-14 18:04 ` hjl.tools at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).