#62 Floating-point Bug

GC 2.2
closed
None
6
2017-04-10
2014-02-02
Edward Hart
No

Floating-point variables start behaving oddly when they are mixed with integer literals. For example, take the following program:

        >>SOURCE FREE
IDENTIFICATION DIVISION.
PROGRAM-ID. testing.

DATA DIVISION.
WORKING-STORAGE SECTION.
01  i USAGE FLOAT-LONG.

PROCEDURE DIVISION.
    PERFORM VARYING i FROM 1 BY 1 UNTIL i > 5
        DISPLAY i " " NO ADVANCING
    END-PERFORM
    .
END PROGRAM testing.

I would expect this to output "1 2 3 4 5 " or something similar, but instead all that is displayed is "1 ".
However, if you add .0 to the end of each of the literals, then the program works perfectly.

cobc --info:

cobc (GNU Cobol) 2.0.0
Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Keisuke Nishida
Copyright (C) 2006-2012 Roger While
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Built     Jan 03 2014 15:06:26
Packaged  Feb 11 2012 12:36:31 UTC
C version "4.8.1"
Build information
Build environment        : x86_64-unknown-linux-gnu
CC                       : gcc -std=gnu99
CPPFLAGS                 : 
CFLAGS                   : -O2 -pipe -finline-functions -fsigned-char
                           -Wall -Wwrite-strings -Wmissing-prototypes
                           -Wno-format-y2k -U_FORTIFY_SOURCE
LD                       : /usr/bin/ld -m elf_x86_64
LDFLAGS                  : -Wl,-z,relro,-z,now,-O1

GNU Cobol information
COB_CC                   : gcc -std=gnu99
COB_CFLAGS               : -I/usr/local/include -pipe
COB_LDFLAGS              : 
COB_LIBS                 : -L/usr/local/lib -lcob -lm -lgmp -lncursesw
                           -ldb -ldl
COB_CONFIG_DIR           : /usr/local/share/gnu-cobol/config
COB_COPY_DIR             : /usr/local/share/gnu-cobol/copy
COB_LIBRARY_PATH         : /usr/local/lib/gnu-cobol
COB_MODULE_EXT           : so
COB_EXEEXT               : 
Dynamic loading          : System
"CBL_" param check       : Disabled
Variable format          : 0
BINARY-C-LONG            : 8 bytes
Sequential handler       : Internal
ISAM handler             : BDB

Discussion

  • Brian Tiffin

    Brian Tiffin - 2014-02-04
    • status: open --> accepted
    • assigned_to: Brian Tiffin
     
  • Simon Sobisch

    Simon Sobisch - 2014-04-17
    • assigned_to: Brian Tiffin --> Ron Norman
     
  • Simon Sobisch

    Simon Sobisch - 2014-04-29

    Fixed along by Ron Norman, committed to 2.x in [r247]

    • status: accepted --> closed
     

    Related

    Commit: [r247]


    Last edit: Simon Sobisch 2016-01-24
  • Simon Sobisch

    Simon Sobisch - 2014-11-24
    • Group: unclassified --> GC 2.0
    • Priority: 1 --> 6
     

Log in to post a comment.