--- Begin Message ---
- To: Debian Bug Tracking System <submit@bugs.debian.org>
- Subject: libc6: strtold is broken on hppa
- From: John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
- Date: Mon, 26 Dec 2005 11:43:50 -0800
- Message-id: <20051226194350.32068.67114.reportbug@gsyprf11.external.hp.com>
Package: libc6
Version: 2.3.5-8
Severity: normal
The following program produces incorrect results:
#include <stdlib.h>
int
main ()
{
printf ("%Lf\n", strtold ("1", NULL));
return 0;
}
dave@gsyprf11:~/gcc_test$ gcc -o ld1 ld1.c
dave@gsyprf11:~/gcc_test$ ./ld1
0.000000
-- System Information:
Debian Release: testing/unstable
APT prefers testing
APT policy: (650, 'testing'), (90, 'unstable')
Architecture: hppa (parisc64)
Shell: /bin/sh linked to /bin/bash
Kernel: Linux 2.6.13-pa1
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)
-- no debconf information
--- End Message ---
--- Begin Message ---
- To: John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
- Cc: 344836-done@bugs.debian.org
- Subject: Re: libc6: strtold is broken on hppa
- From: Aurelien Jarno <aurelien@aurel32.net>
- Date: Sat, 11 Feb 2006 17:52:55 +0100
- Message-id: <20060211165254.GA28877@bode.aurel32.net>
- In-reply-to: <20051226194350.32068.67114.reportbug@gsyprf11.external.hp.com>
- References: <20051226194350.32068.67114.reportbug@gsyprf11.external.hp.com>
Hi!
On Mon, Dec 26, 2005 at 11:43:50AM -0800, John David Anglin wrote:
> Package: libc6
> Version: 2.3.5-8
> Severity: normal
>
> The following program produces incorrect results:
>
> #include <stdlib.h>
> int
> main ()
> {
> printf ("%Lf\n", strtold ("1", NULL));
> return 0;
> }
>
> dave@gsyprf11:~/gcc_test$ gcc -o ld1 ld1.c
> dave@gsyprf11:~/gcc_test$ ./ld1
> 0.000000
>
First of all this behaviour is not specific to hppa.
Secondly this is not bug. Try to build the example code with -Wall:
[bode:/tmp]$ gcc -Wall -o ld1 ./ld1.c
./ld1.c: In function 'main':
./ld1.c:5: warning: implicit declaration of function 'printf'
./ld1.c:5: warning: incompatible implicit declaration of built-in function 'printf'
./ld1.c:5: warning: implicit declaration of function 'strtold'
./ld1.c:5: warning: format '%Lf' expects type 'long double', but argument 2 has type 'int
The problem is that strtold is not declared, so gcc expects it returns
an int, but actually it returns a long double.
It is not declared because it is an ISO C99 function, whereas gcc uses
ISO C89 as the default standard.
To switch to an ISO C99 standard, either pass the -std=gnu99 flag to
gcc, or define _ISOC99_SOURCE or _GNU_SOURCE, or define _XOPEN_SOURCE to
a value greater or egal to 600.
As this is not a bug, I am closing this bug report.
Bye,
Aurelien
--
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73
: :' : Debian developer | Electrical Engineer
`. `' aurel32@debian.org | aurelien@aurel32.net
`- people.debian.org/~aurel32 | www.aurel32.net
--- End Message ---