https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79487
--- Comment #17 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Well, the values are printed. As you say, -9223372036854775808 is not valid
_Decimal32 value, so it should never be printed for something that is
_Decimal32.
Actually trying:
_Decimal32
foo (void)
{
_Decimal32 a = 9999999LL;
_Decimal32 b = 9999999LL;
_Decimal32 c = b + a;
_Decimal32 d = c + a;
_Decimal32 e = d + a;
_Decimal32 f = e + a;
_Decimal32 g = f + a;
_Decimal32 h = g + a;
_Decimal32 i = h + a;
_Decimal32 j = i + a;
_Decimal32 k = j + a;
_Decimal32 l = k + a;
return l;
}
_Decimal32
bar (void)
{
_Decimal128 a = 9999999LL;
_Decimal128 b = 9999999LL;
_Decimal128 c = b + a;
_Decimal128 d = c + a;
_Decimal128 e = d + a;
_Decimal128 f = e + a;
_Decimal128 g = f + a;
_Decimal128 h = g + a;
_Decimal128 i = h + a;
_Decimal128 j = i + a;
_Decimal128 k = j + a;
_Decimal128 l = k + a;
return (_Decimal32) l;
}
I see decimal_round_for_format being called 13 times for _Decimal32 and 10
times for _Decimal128, so clearly at least const_binop does the right thing.
So perhaps in real_from_integer change:
if (fmt.decimal_p ())
decimal_from_integer (r);
- else if (fmt)
+ if (fmt)
real_convert (r, fmt, r);
?