public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH]: Cast in c-pretty-print.c causes warning
@ 2009-08-31 20:34 Kai Tietz
  2009-09-02 19:03 ` Gabriel Dos Reis
  0 siblings, 1 reply; 16+ messages in thread
From: Kai Tietz @ 2009-08-31 20:34 UTC (permalink / raw)
  To: GCC Patches

[-- Attachment #1: Type: text/plain, Size: 615 bytes --]

Hi,

In general it is bad to use size_t to cast point to scalar, but here
in c-pretty-print.c is looks ok, as the scalar is truncated to an
unsigned int type here and just the lowest 16-bit are in fact used.
So here the patch for it

ChangeLog

2009-08-31  Kai Tietz  <kai.tietz@onevision.com>

	* c-pretty-print.c (pp_c_tree_decl_identifier): Use size_t instead of
	'unsigned long' to cast a pointer to scalar.

Tested for i686-pc-mingw32 and x86_64-pc-mingw32. Ok for apply?

Cheers,
Kai


-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

[-- Attachment #2: cprettyprint.diff --]
[-- Type: application/octet-stream, Size: 478 bytes --]

Index: gcc/gcc/c-pretty-print.c
===================================================================
--- gcc.orig/gcc/c-pretty-print.c	2009-05-16 11:49:04.000000000 +0200
+++ gcc/gcc/c-pretty-print.c	2009-08-31 20:08:35.766267700 +0200
@@ -2235,7 +2235,7 @@
   else
     {
       static char xname[8];
-      sprintf (xname, "<U%4x>", ((unsigned)((unsigned long)(t) & 0xffff)));
+      sprintf (xname, "<U%4x>", ((unsigned)((size_t)(t) & 0xffff)));
       name = xname;
     }
 

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2009-09-04  2:12 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-31 20:34 [PATCH]: Cast in c-pretty-print.c causes warning Kai Tietz
2009-09-02 19:03 ` Gabriel Dos Reis
2009-09-02 19:50   ` Kai Tietz
2009-09-02 21:01     ` Richard Henderson
2009-09-02 21:06       ` Kai Tietz
2009-09-02 21:18     ` Gabriel Dos Reis
2009-09-02 21:21       ` Kai Tietz
2009-09-02 22:17         ` Richard Henderson
2009-09-03 10:52           ` Richard Guenther
2009-09-03 13:30             ` Kai Tietz
2009-09-03 13:52               ` Richard Guenther
2009-09-03 14:09                 ` Kai Tietz
2009-09-03 14:11                   ` Richard Henderson
2009-09-03 14:19                     ` Kai Tietz
2009-09-03 15:59                       ` Kai Tietz
2009-09-04  2:12                   ` Gabriel Dos Reis

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).