diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2017-01-06 01:04:41 -0200 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2017-01-06 01:30:59 -0200 |
commit | e6b1bc99739015684f9114d89623329eec4eaf18 (patch) | |
tree | ceb4769e083fbfdba3bc5b8f78398ec3e77d61eb | |
parent | 14d67e5d74bcc455ab7ba5465b70183a84cbb647 (diff) | |
download | gcc-e6b1bc99739015684f9114d89623329eec4eaf18.tar.gz |
[bootstrap-O1] change value type to avoid sprintf buffer size warning
In stage2 of bootstrap-O1, the code that warns if sprintf might
overflow its output buffer cannot tell that an unsigned value narrowed
to 16 bits will fit in 4 bytes with %4x.
Converting the value to 'unsigned short' makes it obvious that it
fits, at least on machines with 16-bit shorts.
for gcc/c-family/ChangeLog
* c-pretty-print.c (pp_c_tree_decl_identifier): Convert 16-bit
value to unsigned short to fit in 4 hex digits without
warnings.
-rw-r--r-- | gcc/c-family/c-pretty-print.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gcc/c-family/c-pretty-print.c b/gcc/c-family/c-pretty-print.c index 90428cac183..29086693301 100644 --- a/gcc/c-family/c-pretty-print.c +++ b/gcc/c-family/c-pretty-print.c @@ -2400,7 +2400,8 @@ pp_c_tree_decl_identifier (c_pretty_printer *pp, tree t) else { static char xname[8]; - sprintf (xname, "<U%4x>", ((unsigned)((uintptr_t)(t) & 0xffff))); + sprintf (xname, "<U%4hx>", ((unsigned short) ((uintptr_t) (t) + & 0xffff))); name = xname; } |