public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* B19: gcc/libc bug with call to atof()   (Win95)
@ 1998-10-27  6:20 Martin Hansen
  1998-10-28  1:33 ` Andres Heinloo
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Martin Hansen @ 1998-10-27  6:20 UTC (permalink / raw)
  To: gnu-win32

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
"gnu-win32-request@cygnus.com" with one line of text: "help".

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~1998-10-28 15:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-10-27  6:20 B19: gcc/libc bug with call to atof() (Win95) Martin Hansen
1998-10-28  1:33 ` Andres Heinloo
1998-10-28  6:00 ` Stephen Vance
1998-10-28  8:50 ` Mumit Khan
1998-10-28 15:58 ` Peter A. Vogel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).