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

            Bug ID: 128380
           Summary: string_to_real ignores the exponent part
           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: ---

string_to_real (and the long and long long variants generated from
the same template) in libga68/standard.a68.in, line 392:


bool safe := if e < UPB s
             then {L} int tmp := {K} expart;
                  bool b = string_to_{L_}int (s[e+1:], 10, tmp);
                  expart = {S} tmp;
                  b
             else true
             fi;


expart = {S} tmp is a comparison whose result is voided, not an
assignment, so expart stays 0.


begin
    real r := 0.0;
    bool b = string_to_real ("+1.5^+2", r);
    puts ((b | "true " | "false ") + float (r, 12, 4, 3) + "'n");
    long real lr := long 0.0;
    bool lb = string_to_long_real ("+1.5^+2", lr);
    puts ((lb | "true " | "false ") + float (lr, 14, 6, 3) + "'n")
end


Output:


true +15.0000e -1
true +15.000000e -1


Expected: 150, i.e. +15.0000e +1 and +15.000000e +1.

Reply via email to