Path: utzoo!attcan!uunet!lll-winken!lll-tis!ames!mailrus!cornell!rochester!srs!dan From: dan@srs.UUCP (Dan Kegel) Newsgroups: comp.unix.wizards Subject: bug in strtod in SunOS 3.2 Summary: strtod passes back bad char ptr Message-ID: <936@srs.UUCP> Date: 21 Jul 88 18:41:25 GMT Reply-To: srs!dan@cs.rochester.edu (Dan Kegel) Organization: S.R.Systems Lines: 35 cc: sunbugs@sun.uucp 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 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@cs.rochester.edu rochester!srs!dan dan%srs.uucp@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@cs.rochester.edu rochester!srs!dan dan%srs.uucp@harvard.harvard.edu