Merry Christmas!
The code related to integer output in libgfortran has accumulated some…
oddities over the years. I will soon post a finalized patch for faster
integer-to-decimal conversion (see
https://gcc.gnu.org/pipermail/fortran/2021-December/057201.html), but while
working on that I found a couple of things we ought to fix, that are not
directly related.
So this patch is a simplification patch, a no-op. It does the following things:
- gfc_itoa() is always called for nonnegative values, to make it take an
unsigned arg. It allows us to simplify the code handling for negative signs
(instead of doing it in two places).
- fix undefined behaviour on possible overflow when negating large negative
values (-HUGE-1)
- all callers of write_decimal() always use gfc_itoa() as conversion function,
so remove one layer of indirection: get rid of that argument, call gfc_itoa()
directly inside write_decimal()
- gfc_xtoa() is only used in one file anymore, so move it there and rename it
to xtoa()
- ztoa_big() is renamed to xtoa_big(), following the convention of other
?to_big() functions
- runtime/backtrace.c is the only user of gfc_itoa() outside the I/O system;
add a comment so we remember in the future why we use gfc_itoa() there… and
what are its limits
All this makes the code easier to understand, more consistent, probably
marginally more efficient (the gfc_itoa pointer indirection), and will make the
future work on speeding up gfc_itoa() easier.
Bootstrapped and regtested on x86_64-pc-linux-gnu.
OK to commit?
FX
itoa.patch
Description: Binary data