c/442: atof can give incorrect output

lrwayne@earthlink.net lrwayne@earthlink.net
Thu Aug 3 00:26:00 GMT 2000


>Number:         442
>Category:       c
>Synopsis:       atof can give incorrect output
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Aug 03 00:26:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     Len Wayne
>Release:        egcs-2.91.66
>Organization:
>Environment:
i686 running Red Hat 6.1 Linux
>Description:
If <stdlib.h> is not included in a program,
then a call to atof should fail.  Instead, 
atof returns some output, and that output 
is incorrect. For example, this program allows
atof to run, but atof returns an incorrect
value (something other than 4.4):

-----------------------------------------
int main () {
  printf("%f\n",atof("4.4"));
}
-----------------------------------------

I'm compiling with the command:  gcc foo.c

I'm not a good enough programmer to figure
out what library contains the (apparently
bogus) version of atof that is being
accessed by this program, but it certainly
seems like this program should fail to
compile if <stdlib.h> is not included,
rather than return incorrect results.
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the Gcc-prs mailing list