Re: [PATCH, fortran] PR93727 Implement new EX format specifier

"H.J. Lu" <[email protected]>
Newsgroups gmane.comp.gcc.patches,gmane.comp.gcc.fortran
Message-ID <CAMe9rOrqTXmgDR186RD3AeD-a-fA+ND5YEWSHMACADya1dp3qg@mail.gmail.com>
On Mon, May 25, 2026 at 3:16 AM Jerry D <[email protected]> wrote:
>
> On 5/24/26 12:38 AM, H.J. Lu wrote:
> > Note: The following floating-point exceptions are signalling:
> > IEEE_INVALID_FLAG IEEE_UNDERFLOW_FLAG IEEE_DENORMAL
> > STOP 3
> > FAIL: gfortran.dg/EXformat_1.F90   -O0  execution test
>
> I fed the above and the CI report I received to Claude and it
> arrived at the attached patch rather quickly.  Can you try this and confirm
> whether it fixes it or not?

Yes, it works.

Thanks.

> Regards,
>
> Jerry
>
> ---------------
>
>  From 837ca2b4c3d1069ddb938a5a7c259d34a85479fc Mon Sep 17 00:00:00 2001
> From: Jerry DeLisle <[email protected]>
> Date: Sun, 24 May 2026 11:51:49 -0700
> Subject: [PATCH] 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.
>
> The kind=10 case already used unsigned long long for the same reason.
> Fix kind=8 to match: change the type, the cast, and the two %lX
> format specifiers to %llX.
>
>         PR fortran/93727
>
> libgfortran/ChangeLog:
>
>         * io/write_float.def (get_float_hex_string): Change frac_part
>         for kind=8 from unsigned long to unsigned long long and update
>         format specifiers from %13.13lX to %13.13llX to fix truncated
>         hex output and IEEE_INVALID_FLAG on ILP32 targets.
>
> Assisted by: Claude Sonnet 4.6
>


-- 
H.J.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.