bug in strtod in SunOS 3.2

Dan Kegel dan at srs.UUCP
Fri Jul 22 04:41:25 AEST 1988


Sun's strtod is supposed to pass a pointer to the first char after the float
that was parsed, but it seems to think that the terminating null char is
part of the float.
Is this 'fixed in 4.0'?

Repeat by running this program:
    #include <stdio.h>

    main()
    {
	double strtod();
	char *str = "42";
	char *p;
	float foo;

	foo = strtod(str, &p);
	printf("str = %s; strtod(str,&p) returns %f, p - str = %d, *p = %d\n",
	    str, foo, p - str, *p);
    }
Here's the output of the program on an IBM PC running MSC 4.0, showing correct
result:
    str = 42; strtod(str,&p) returns 42.000000, p - str = 2, *p = 0

Here's the output of the program on a Sun-3 running SunOS 3.2, showing wrong
result:
    str = 42; strtod(str,&p) returns 42.000000, p - str = 3, *p = 115

----
Dan Kegel   "We had to get it passed before the columnists attacked!"
srs!dan at cs.rochester.edu  rochester!srs!dan dan%srs.uucp at harvard.harvard.edu

p.s.  What kind of tests does Sun use to check every library function before
shipping a new release?
-- 
  Dan Kegel   "We had to get it passed before the columnists attacked!"
  srs!dan at cs.rochester.edu  rochester!srs!dan dan%srs.uucp at harvard.harvard.edu



More information about the Comp.unix.wizards mailing list