This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/2177] New: strtof and strtold gives garbage results


This test case produces garbage results.  It seems that compiling without
-std=c99 selects different versions of strtof and strtold (via the headers) that
give incorrect results:

/* How to reproduce:
 *      gcc foo.c -o foo                # fails
 *      gcc foo.c -o foo -std=c99       # works
 */

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

int main ()
{
  float f = strtof ("1.2", NULL);
  printf ("%g\n", f);
  return 0;
}

It's controlled by these #ifdefs:

# ifdef __USE_ISOC99
__BEGIN_NAMESPACE_C99
extern __inline float
__NTH (strtof (__const char *__restrict __nptr, char **__restrict __endptr))
{
  return __strtof_internal (__nptr, __endptr, 0);
}
extern __inline long double
__NTH (strtold (__const char *__restrict __nptr, char **__restrict __endptr))
{
  return __strtold_internal (__nptr, __endptr, 0);
}
__END_NAMESPACE_C99
# endif

It's what happens when these variants are -not- used that seems to be the
problem.  I am using gcc (GCC) 4.0.3 20060115 (prerelease) (Debian 4.0.2-7) and
glibc 2.3.5-12 from Debian.

-- 
           Summary: strtof and strtold gives garbage results
           Product: glibc
           Version: 2.3.5
            Status: NEW
          Severity: critical
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: bje at sources dot redhat dot com
                CC: glibc-bugs at sources dot redhat dot com
  GCC host triplet: i686-pc-linux-gnu


http://sourceware.org/bugzilla/show_bug.cgi?id=2177

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]