aboutsummaryrefslogtreecommitdiff
path: root/gcc/gimple-ssa-sprintf.c
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2017-04-25 17:40:58 +0000
committerMartin Sebor <msebor@gcc.gnu.org>2017-04-25 11:40:58 -0600
commite602bbfc30cd7d40509edaba120429dc4a92cbce (patch)
tree46f475ef5106615483c9a5128dfd8f3f33fd2ff2 /gcc/gimple-ssa-sprintf.c
parent8e640712d5af13fec089a36c6f7fa089ffc2d062 (diff)
downloadgcc-e602bbfc30cd7d40509edaba120429dc4a92cbce.zip
gcc-e602bbfc30cd7d40509edaba120429dc4a92cbce.tar.gz
gcc-e602bbfc30cd7d40509edaba120429dc4a92cbce.tar.bz2
PR tree-optimization/80497 - ICE at -O1 and above on valid code on x86_64-linux-gnu in tree_to_uhwi
gcc/ChangeLog: PR tree-optimization/80497 * gimple-ssa-sprintf.c (get_int_range): Avoid assuming all integer constants are representable in HOST_WIDE_INT. (parse_directive): Ditto. gcc/testsuite/ChangeLog: PR tree-optimization/80497 * gcc.dg/tree-ssa/builtin-sprintf-warn-17.c: New test. From-SVN: r247262
Diffstat (limited to 'gcc/gimple-ssa-sprintf.c')
-rw-r--r--gcc/gimple-ssa-sprintf.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/gcc/gimple-ssa-sprintf.c b/gcc/gimple-ssa-sprintf.c
index 2e62086..d3771dd 100644
--- a/gcc/gimple-ssa-sprintf.c
+++ b/gcc/gimple-ssa-sprintf.c
@@ -948,7 +948,8 @@ get_int_range (tree arg, HOST_WIDE_INT *pmin, HOST_WIDE_INT *pmax,
*pmin = tree_to_shwi (TYPE_MIN_VALUE (type));
*pmax = tree_to_shwi (TYPE_MAX_VALUE (type));
}
- else if (TREE_CODE (arg) == INTEGER_CST)
+ else if (TREE_CODE (arg) == INTEGER_CST
+ && TYPE_PRECISION (TREE_TYPE (arg)) <= TYPE_PRECISION (type))
{
/* For a constant argument return its value adjusted as specified
by NEGATIVE and NEGBOUND and return true to indicate that the
@@ -2916,7 +2917,9 @@ parse_directive (pass_sprintf_length::call_info &info,
if (width != -1)
dollar = width + info.argidx;
else if (star_width
- && TREE_CODE (star_width) == INTEGER_CST)
+ && TREE_CODE (star_width) == INTEGER_CST
+ && (TYPE_PRECISION (TREE_TYPE (star_width))
+ <= TYPE_PRECISION (integer_type_node)))
dollar = width + tree_to_shwi (star_width);
/* Bail when the numbered argument is out of range (it will