https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120631
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The releases/gcc-15 branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:b89ee9e63ce7dff24dfab95f8df123e71629f5ff commit r15-9847-gb89ee9e63ce7dff24dfab95f8df123e71629f5ff Author: Jakub Jelinek <ja...@redhat.com> Date: Wed Jun 18 08:07:22 2025 +0200 dfp, real: Fix up FLOAT_EXPR/FIX_TRUNC_EXPR constant folding between dfp and large _BitInt [PR120631] The following testcase shows that while at runtime we handle conversions between _Decimal{64,128} and large _BitInt correctly, at compile time we mishandle them in both directions, in one direction we end up in ICE in decimal_from_integer callee because the char buffer is too short for the needed number of decimal digits, in the conversion of dfp to large _BitInt we return 0 in the wide_int. The following patch fixes the ICE by using larger buffer (XALLOCAVEC allocated, it will be never larger than 65536 / 3 bytes) in the larger _BitInt case, and the other direction by setting exponent to exp % 19 and instead multiplying the result by needed powers of 10^19 (10^19 chosen as largest power of ten that can fit into UHWI). 2025-06-18 Jakub Jelinek <ja...@redhat.com> PR middle-end/120631 * real.cc (decimal_from_integer): Add digits argument, if larger than 256, use XALLOCAVEC allocated buffer. (real_from_integer): Pass val_in's precision divided by 3 to decimal_from_integer. * dfp.cc (decimal_real_to_integer): For precision > 128 if finite and exponent is large, decrease exponent and multiply resulting wide_int by powers of 10^19. * gcc.dg/dfp/bitint-9.c: New test. (cherry picked from commit f3002d664d1137844c714645a841a48ab57d0eaa)