https://gcc.gnu.org/g:891d1d0fcdc614de729553df7de41e2148b88692
commit r16-7950-g891d1d0fcdc614de729553df7de41e2148b88692 Author: Jose E. Marchesi <[email protected]> Date: Sun Mar 8 19:14:32 2026 +0100 a68: fix calls to strtol and stroll [PR algol68/124372] This commit fixes the following problems related to parsing integer and bits denotations: 1. strtou?l should be used only if itis 64-bit long. Otherwise, use strtou?l. 2. Use unsigned conversions for bits denotations radix, for consistency. Tested in i686-linux-gnu and x86_64-linux-gnu. Signed-off-by: Jose E. Marchesi <[email protected]> gcc/algol68/ChangeLog PR algol68/124372 * a68-low-units.cc (a68_lower_denotation): Call to strtoull if INT64_T_IS_LONG is not defined, strtol otherwise. * a68-parser-scanner.cc (get_next_token): Use strtoul for radix instead of strtol. Diff: --- gcc/algol68/a68-low-units.cc | 20 +++++++++++++++----- gcc/algol68/a68-parser-scanner.cc | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gcc/algol68/a68-low-units.cc b/gcc/algol68/a68-low-units.cc index 86eb68cc141c..3cbf131112b1 100644 --- a/gcc/algol68/a68-low-units.cc +++ b/gcc/algol68/a68-low-units.cc @@ -287,18 +287,28 @@ a68_lower_denotation (NODE_T *p, LOW_CTX_T ctx) s = SUB (p); type = CTYPE (moid); - int64_t radix = strtol (NSYMBOL (s), &end, 10); - gcc_assert (end != NSYMBOL (s) && *end == 'r'); + errno = 0; +#if defined(INT64_T_IS_LONG) + uint64_t radix = strtoul (NSYMBOL (s), &end, 10); +#else + uint64_t radix = strtoull (NSYMBOL (s), &end, 10); +#endif + gcc_assert (errno == 0 && end != NSYMBOL (s) && *end == 'r'); end++; - int64_t val = strtol (end, &end, radix); - gcc_assert (end[0] == '\0'); + errno = 0; +#if defined(INT64_T_IS_LONG) + uint64_t val = strtoul (end, &end, radix); +#else + uint64_t val = strtoull (end, &end, radix); +#endif + gcc_assert (errno == 0 && end[0] == '\0'); return build_int_cst (type, val); } else if (moid == M_REAL || moid == M_LONG_REAL || moid == M_LONG_LONG_REAL) { - /* SIZETY INT */ + /* SIZETY REAL */ tree type; NODE_T *s = NO_NODE; if (IS (SUB (p), LONGETY) || IS (SUB (p), SHORTETY)) diff --git a/gcc/algol68/a68-parser-scanner.cc b/gcc/algol68/a68-parser-scanner.cc index af1251f125df..097accd5322d 100644 --- a/gcc/algol68/a68-parser-scanner.cc +++ b/gcc/algol68/a68-parser-scanner.cc @@ -1675,8 +1675,9 @@ get_next_token (bool in_format, /* Parse the radix, which is expressed in base 10. */ (sym++)[0] = c; char *end; - int64_t radix = strtol (A68_PARSER (scan_buf), &end, 10); - gcc_assert (end != A68_PARSER (scan_buf) && *end == 'r'); + errno = 0; + uint64_t radix = strtoul (A68_PARSER (scan_buf), &end, 10); + gcc_assert (errno == 0 && end != A68_PARSER (scan_buf) && *end == 'r'); /* Get the rest of the bits literal. Typographical display features are allowed in the reference language between the digit symbols
