delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/1996/11/15/00:02:04

From: khan AT xraylith DOT wisc DOT edu (Mumit Khan)
Subject: Nasty problem in atof/strtod
15 Nov 1996 00:02:04 -0800 :
Sender: daemon AT cygnus DOT com
Approved: cygnus DOT gnu-win32 AT cygnus DOT com
Distribution: cygnus
Message-ID: <9611150415.AA08972.cygnus.gnu-win32@modi.xraylith.wisc.edu>
Original-To: gnu-win32 AT cygnus DOT com
Original-Sender: owner-gnu-win32 AT cygnus DOT com

The following makes strtod choke and die with very little persuasion!

    #include <stdlib.h>
    #include <stdio.h>

    int main() {
	double val = atof("2.60788366e-20");
	printf ("val = %f\n", val);
	return 0;
    }

    % gcc -g -o atofbug.exe atofbug.c -Wall
    % gdb atof
    (gdb) run
    Program received signal SIGSEGV, Segmentation fault.
    0x781804 in ?? ()
    (gdb) where
    #0  0x781804 in ?? ()
    #1  0x1001baf8 in strtod (s00=0x401014 "-2.60788336e-20", se=0x0)
	at /sethra/death/noer/beta16/src/newlib/libc/stdlib/strtod.c:717
    #2  0x10016ad9 in atof (s=0x401014 "-2.60788336e-20")
	at /sethra/death/noer/beta16/src/newlib/libc/stdlib/atof.c:71
    #3  0x401045 in main () at atof.c:5
    #4  0x10001ebb in dll_crt0_1 (uptr=0x402000)
	at /sethra/death/noer/beta16/src/winsup/dcrt0.cc:520
    #5  0x10001ecf in dll_crt0 (uptr=0x402000)
	at /sethra/death/noer/beta16/src/winsup/dcrt0.cc:532
    #6  0x40111c in cygwin_crt0 ()
	at /sethra/death/noer/beta16/src/winsup/libccrt0.cc:89

btw, works fine for e-19, but e-20 is the breaking point.

Came across this while fighting to make g77 0.5.18 work correctly with
B16. Only took 5 hours to narrow it down to 4 lines of code :-)

Anyone else run across this? I'm using a cross-compiler hosted on my
RH 4.0 i486-linux box, but this particular example was built with
B16 binary distribution, so should be independent of any screwup in
my local config.

regards,
Mumit -- khan AT xraylith DOT wisc DOT edu
http://www.xraylith.wisc.edu/~khan
-
For help on using this list, send a message to
"gnu-win32-request AT cygnus DOT com" with one line of text: "help".

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019