gcc/ChangeLog:
* gimple-ssa-sprintf.c (tree_digits): Avoid negating TYPE_MIN.
From-SVN: r244511
+2017-01-16 Martin Sebor <msebor@redhat.com>
+
+ PR tree-optimization/78608
+ * gimple-ssa-sprintf.c (tree_digits): Avoid negating TYPE_MIN.
+
2017-01-16 Jeff Law <law@redhat.com>
Revert:
if (tree_fits_shwi_p (x))
{
HOST_WIDE_INT i = tree_to_shwi (x);
- if (i < 0)
- {
- absval = -i;
- res = 1;
- }
- else
- {
- absval = i;
- res = plus;
- }
+ if (HOST_WIDE_INT_MIN == i)
+ {
+ /* Avoid undefined behavior due to negating a minimum. */
+ absval = HOST_WIDE_INT_MAX;
+ res = 1;
+ }
+ else if (i < 0)
+ {
+ absval = -i;
+ res = 1;
+ }
+ else
+ {
+ absval = i;
+ res = plus;
+ }
}
else
return -1;