| Summary: | strtold() returns meaningless number on Asus WL-500gP router w/OpenWRT | ||
|---|---|---|---|
| Product: | uClibc | Reporter: | Charles Kerr <charles> |
| Component: | Standard Compliance | Assignee: | unassigned |
| Status: | RESOLVED WORKSFORME | ||
| Severity: | normal | CC: | uclibc-cvs |
| Priority: | P5 | ||
| Version: | <= 0.9.29.x | ||
| Target Milestone: | --- | ||
| Hardware: | Other | ||
| OS: | Linux | ||
| Host: | Target: | ||
| Build: | |||
|
Description
Charles Kerr
2009-10-14 13:12:46 UTC
This sounds more like a miscompilation to me, but i don't know what hardware that router is.
I'm closing this for now since it works for me (see below). Don't hesitate to reopen if you can provide more detail.
thanks,
$ gcc -Os strtold.c && ./a.out
Lg=2
g =2
f =2.000000
$ cat strtold.c
#include <stdlib.h>
#include <stdio.h>
int main(void) {
printf("Lg=%Lg\n", strtold("2.0000", NULL));
printf("g =%g\n", strtod("2.0000", NULL));
printf("f =%f\n", strtof("2.0000", NULL));
return 0;
}
I also can confirm erroneous strtold() output on MIPS32 LE platform. Your sample produces output like:
$ ./strtold
Lg=2.122e-314
g =2
f =0.000000
toolchain used: gcc is 4.2.4, uClibc 0.9.30.1, binutils 2.19.1
If I changes example like:
#include <stdlib.h>
#include <stdio.h>
int main(void) {
long double ld = 0;
float f = 0;
ld = strtold("2.0000", NULL);
f = strtof("2.0000", NULL);
printf("Lg=%Lg\n", ld);
printf("g =%g\n", strtod("2.0000", NULL));
printf("f =%f\n", f);
return 0;
}
output will be:
$ ./strtold
Lg=7.16427e+08
g =2
f =716427264.000000
Sorry, this is a kind of miscompilation bug - according to strtold manual, it REQUIRES even for glibc:
==========================================================================
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
strtof(), strtold(): _XOPEN_SOURCE >= 600 || _ISOC99_SOURCE; or
cc -std=c99
==========================================================================
I simply forgot to provide -std=c99 when compiling test-case, so please close the bug.
|