int_size_in_bytes() returns HOST_WIDE_INT (64-bit), theoretically, the
maximized size is 23 -- it is sizeof("[-9223372036854775808]") for
0x8000000000000000LL.

It may not cause real world issue, but if another issues occur, it may
lead things worse.

It passes normal testsuite: "../gcc/configure && make && make check" is
OK. And 'contrib/compare_tests' is OK, too, the related output is:

  # Comparing directories
  ## Dir1=/upstream/build-gcc: 11 sum files
  ## Dir2=/upstream/build-gcc-new: 11 sum files

  # Comparing 11 common sum files
  ## /bin/sh ./compare_tests  /tmp/gxx-sum1.7678 /tmp/gxx-sum2.7678
  # No differences found in 11 common sum files


2014-08-17  Chen Gang  <gang.chen.5...@gmail.com>

        * c/c-aux-info.c (gen_type): Resize 'buff' from 10 to 23 bytes,
        with using HOST_WIDE_INT without truncation to 'int'

---
 gcc/c/c-aux-info.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/gcc/c/c-aux-info.c b/gcc/c/c-aux-info.c
index 4b6b2d0..878807b 100644
--- a/gcc/c/c-aux-info.c
+++ b/gcc/c/c-aux-info.c
@@ -310,9 +310,10 @@ gen_type (const char *ret_val, tree t, formals_style style)
                                TREE_TYPE (t), style);
          else
            {
-             int size = (int_size_in_bytes (t) / int_size_in_bytes (TREE_TYPE 
(t)));
-             char buff[10];
-             sprintf (buff, "[%d]", size);
+             char buff[23];
+             sprintf (buff, "["HOST_WIDE_INT_PRINT_DEC"]",
+                      int_size_in_bytes (t)
+                      / int_size_in_bytes (TREE_TYPE (t)));
              ret_val = gen_type (concat (ret_val, buff, NULL),
                                  TREE_TYPE (t), style);
            }

Reply via email to