https://gcc.gnu.org/g:2b6d3cd7aee5cabacc35962e48ed4d96c6cb48d4

commit r17-4476-g2b6d3cd7aee5cabacc35962e48ed4d96c6cb48d4
Author: Jose E. Marchesi <[email protected]>
Date:   Sun Sep 20 05:13:33 2026 +0200

    a68: fix overflow detection in long bits denotations
    
    Signed-off-by: Jose E. Marchesi <[email protected]>
    
    gcc/algol68/ChangeLog
    
            * a68-low-units.cc (a68_lower_denotation): strtoul can return
            errno /= 0 in overflow.
    
    gcc/testsuite/ChangeLog
    
            * algol68/compile/error-bits-denotation-1.a68: Test for overflow
            of bits and long bits.

Diff:
---
 gcc/algol68/a68-low-units.cc                              | 3 +--
 gcc/testsuite/algol68/compile/error-bits-denotation-1.a68 | 5 +++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/gcc/algol68/a68-low-units.cc b/gcc/algol68/a68-low-units.cc
index ed92a1fd5178..ac7accd9051a 100644
--- a/gcc/algol68/a68-low-units.cc
+++ b/gcc/algol68/a68-low-units.cc
@@ -301,8 +301,7 @@ a68_lower_denotation (NODE_T *p, LOW_CTX_T ctx)
 #else
       uint64_t val = strtoull (end, &end, radix);
 #endif
-      gcc_assert (errno == 0 && end[0] == '\0');
-
+      gcc_assert (end[0] == '\0');
       uint64_t max_positive = uint64_t (wi::max_value (type).to_uhwi ());
       if (errno == ERANGE || val > max_positive)
        {
diff --git a/gcc/testsuite/algol68/compile/error-bits-denotation-1.a68 
b/gcc/testsuite/algol68/compile/error-bits-denotation-1.a68
index 455007c29056..75bf07bf3b08 100644
--- a/gcc/testsuite/algol68/compile/error-bits-denotation-1.a68
+++ b/gcc/testsuite/algol68/compile/error-bits-denotation-1.a68
@@ -2,5 +2,10 @@ begin short short bits a
             = short short 10r256; { dg-error "denotation is too large for 
short short bits" }
       short bits b
             = short 16rffff1; { dg-error "denotation is too large for short 
bits" }
+      bits c
+           = 16rffffffff1; { dg-error "denotation is too large for bits" }
+      long bits d
+           = long 16rffffffffffffffff1; { dg-error "denotation is too large 
for long bits" }
+
       skip
 end

Reply via email to