Bug 115453 - strtof is broken
Summary: strtof is broken
Status: CLOSED NOTABUG
Alias: None
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: glibc   
(Show other bugs)
Version: 2.1
Hardware: i686
OS: Linux
high
high
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Brian Brock
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2004-02-12 17:18 UTC by Ragnar Hojland Espinosa
Modified: 2016-11-24 15:23 UTC (History)
1 user (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-02-13 12:27:21 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Ragnar Hojland Espinosa 2004-02-12 17:18:54 UTC
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040120

Description of problem:
#include <stdlib.h>
main()
{
   printf ("%f\n", strtof ("+5.7344E+02", 0));
   return 0;
}

erroneously prints:
0.000000

and worse,

#include <stdlib.h>
main()
{
   char foo;
   printf ("%f\n", strtof ("+5.7344E+02", 0));
   return 0;
}

prints:
245504.625029


Version-Release number of selected component (if applicable):
glibc-2.2.4-26

How reproducible:
Always

Steps to Reproduce:
compile above

Additional info:

No rpms have been updated; this bug is also present in more modern glibcs.

Comment 1 Jakub Jelinek 2004-02-13 12:27:21 UTC
If you used -Wall option, GCC would tell you what's wrong:
/tmp/x.c:3: warning: return type defaults to `int'
/tmp/x.c: In function `main':
/tmp/x.c:4: warning: implicit declaration of function `printf'
/tmp/x.c:4: warning: implicit declaration of function `strtof'
/tmp/x.c:4: warning: double format, different type arg (arg 2)

The problem is that strtof, being ISO C99+ function, is not prototyped
in ISO C90 compilations, as that would violate namespace rules.
See info libc on Feature Set Macros.
Compiling with -std=c99, -std=gnu99, -D_GNU_SOURCE or -D_ISOC99_SOURCE
(and also #include <stdio.h> for printf while you're at it) will fix it up.


Note You need to log in before you can comment on or make changes to this bug.