🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #42344

Re: Bug in gcc, libc, or programmer?

#42344
From: Rask Lambertsen
Date: Wed, 13 Dec 1995 00:00
43 lines
1847 bytes
On Tue, 12 Dec 1995 22:30:05 +0000 taavo r (taavo@taavo1.roc.servtech.com) wrote:
> What is wrong with this piece of code?.  The strtod()
> was breaking a program I had, but atof seems to work...

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

> int main()
> {
> 	double dPi, dZero, dPi2;
> 	char szPi[]="3.14";

> 	dPi = strtod ( szPi, NULL);
> 	dPi2 = atof (szPi);
> 	dZero = dPi - dPi2;

> 	printf ("\nPi: %f Pi2: %f Zero: %f", dPi, dPi2, dZero);
> 	return 1;
> }

> when compiled and run on a gcc 263, SunOS 4.1.3, here
> is the (screwed up) output:

> $a.out

> $Pi: -134218664.000000 Pi2: 3.140000 Zero: -134218

   I remember a similar case from the Amiga GCC mailing list. It was
traced to a missing prototype. Try seeing if the prototype for strtod()
is missing, or try inserting it yourself:

double strtod (const char *str, char **ptr);

If this helps, then you have either forgot an #include or one of the
included files are buggy.

--
Regards,

/�������������������������������������������������������������������������\
| Rask Ingemann Lambertsen       | E-mail: gc948374@gbar.dtu.dk           |
| Amiga GNU CC README maintainer | WWW: http://www.gbar.dtu.dk/~gc948374/ |
| Keyboard error: <Ctrl> and <Alt> are stuck - press <Del> to continue    |
Technical Details
Message-ID: <4ank2u$3ug@unidhp.uni-c.dk>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <30CE026D.380E7120@taavo1.roc.servtech.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 11318c,b762babb78f8c3a3
X-Google-Attributes: gid11318c,public
From: gc948374@bohr.gbar.dtu.dk (Rask Lambertsen)
Subject: Re: Bug in gcc, libc, or programmer?
Date: 1995/12/13
Message-ID: <4ank2u$3ug@unidhp.uni-c.dk>
X-Deja-AN: 121757932
references: <30CE026D.380E7120@taavo1.roc.servtech.com>
organization: DTU
newsgroups: gnu.gcc.help