Subject: B19: gcc/libc bug with call to atof() (Win95)
From: [email-masked] (Martin Hansen)

27 Oct 1998 20:42:28 -0800
Message-ID: <[email-masked]>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: [email-masked]

Dear list,

in my version of gnu-win32 I encounter the following bug with
gcc/libc.  
I have the gnu-win32 version B19 running under Win95 (4.00.950 B).
Within the gnu-win32 distribution I have the gcc version
% gcc -v
Reading specs from C:\CYGNUS\B19\H-I386~1\lib\gcc-lib\i386-cygwin32\2.7-B19\specs
gcc driver version 2.7-B19 executing gcc version 2.7-97r2aBeta

The following small program produces the bug:

/* test_atof.c */

#include <stdio.h>

main(int argc, char **argv)
{
   while (--argc)
   {
      printf("\narg %d is %s\n", argc, argv[argc]);
      printf("arg %d : value as float %f\n", argc, atof(argv[argc]));
      printf("arg %d : value as   int %d\n", argc, atoi(argv[argc]));
   }
}

/* End of file */

Compile the program by
    % gcc test_atof.c
The program compiles and I don't get any error about the missing line
"#include <stdlib.h>", where atoi() and atof() are declared.  (This is
the bug, part1)
 
Try the program with
    % test_atof  3.3 4.7
The result is

arg 2 is 4.7
arg 2 : value as float 0.000000
arg 2 : value as   int 4

arg 1 is 3.3
arg 1 : value as float 0.000000
arg 1 : value as   int 3

which is wrong for the float value but right for the int value.  (This
is the bug, part2).  First when you add the line '#include <stdlib.h>'
to the program and recompile it, you get the desired behaviour.
-
For help on using this list (especially unsubscribing), send a message to
"[email-masked]" with one line of text: "help".