https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93727

--- Comment #36 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jerry DeLisle <[email protected]>:

https://gcc.gnu.org/g:c5eff89d859f98bf9e896eff22a65d1bbf0c5104

commit r17-710-gc5eff89d859f98bf9e896eff22a65d1bbf0c5104
Author: Jerry DeLisle <[email protected]>
Date:   Sun May 24 11:51:49 2026 -0700

    Fortran: [PR93727] Fix EX format kind=8 output on ILP32 targets

    On 32-bit targets such as ARM where unsigned long is 32 bits, the
    kind=8 case in get_float_hex_string used unsigned long for frac_part.
    The kind=8 mantissa requires 52 bits (13 hex digits), so the cast
    silently truncated the upper bits, producing wrong hex output.  In
    addition, converting a ~4.5e15 double value to a 32-bit unsigned long
    is out of range, which raised IEEE_INVALID_FLAG on ARM hardware.

    Fix kind=8 by using GFC_UINTEGER_8, which is guaranteed 64 bits on all
    targets.  Update kind=10 and kind=16 to use GFC_UINTEGER_8 throughout
    for consistency with libgfortran conventions.

            PR fortran/93727

    libgfortran/ChangeLog:

            * io/write_float.def (get_float_hex_string): Fix kind=8 frac_part
            from unsigned long to GFC_UINTEGER_8 to correct truncated hex
            output and IEEE_INVALID_FLAG on ILP32 targets.  Update kind=10
            and kind=16 to use GFC_UINTEGER_8 for consistency.

            Assisted by: Claude Sonnet 4.6

Reply via email to