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

            Bug ID: 128382
           Summary: fixed with width 0 loops forever for large values
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: algol68
          Assignee: algol68 at gcc dot gnu.org
          Reporter: stefan.zobel at gmail dot com
  Target Milestone: ---

fixed in libga68/standard.a68.in, line 217:


while y + {L} .5 * {L} .1 ** after >= {L} 10 ** length
do length +:= 1 od;


{L} 10 is an integer denotation, so {L} 10 ** length is computed in
{L} int. For real this is a 32-bit int, so 10 ** 10 already
overflows (ga68 gives 1410065408), and from 10 ** 32 on the wrapped
value is 0, so the condition stays true and the loop never ends. For
long real the same happens from 1e19 on.


begin
    puts (fixed (1.0e9, 0, 1) + "'n");
    puts (fixed (1.0e10, 14, 1) + "'n");
    puts (fixed (long 1.0e18, 0, 1) + "'n");
    puts (whole (10 ** 10, 0) + " " + whole (10 ** 32, 0) + "'n");
    puts (fixed (long 1.0e19, 0, 1) + "'n")
end


Output (`timeout 10`, exit status 124):


1000000000.0
+10000000000.0
1000000000000000000.0
1410065408 0

Reply via email to