From owner-freebsd-bugs Thu Feb 26 09:38:29 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id JAA21049 for freebsd-bugs-outgoing; Thu, 26 Feb 1998 09:38:29 -0800 (PST) (envelope-from owner-freebsd-bugs@FreeBSD.ORG) Received: from fly.HiWAAY.net (root@fly.HiWAAY.net [208.147.154.56]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id JAA21042 for ; Thu, 26 Feb 1998 09:38:27 -0800 (PST) (envelope-from sprice@hiwaay.net) Received: from bonsai.hiwaay.net (tnt3-163.HiWAAY.net [208.147.146.163]) by fly.HiWAAY.net (8.8.8/8.8.6) with SMTP id LAA23878; Thu, 26 Feb 1998 11:38:07 -0600 (CST) Message-ID: <34F5A8AB.3D0D0DF2@hiwaay.net> Date: Thu, 26 Feb 1998 11:38:51 -0600 From: Steve Price X-Mailer: Mozilla 3.04Gold (X11; I; FreeBSD 3.0-CURRENT i386) MIME-Version: 1.0 To: "Aryeh M. Friedman" CC: freebsd-bugs@FreeBSD.ORG Subject: Re: misc/5856 References: <199802261702.JAA16425@void.rad-inet.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org Aryeh M. Friedman wrote: > > This should be better doced in various places since I used to k&r where > if no proto for a lib is found it assumes it is the same ret type as ther > caller "expects" it to be > ./ I'm pretty sure this is not the case. In K&R style code you will generally see something like the following: main() { double atof(), foo; foo = atof("1.345"); printf("%f", foo); return 0; } Which does indeed work as expected. What may be confusing you is that in the absence of a declaration a K&R compiler will assume that the return type is int, just as it does with main function above. So what you say will appear true in every instance of a function that truly returns an int. So in your example the absence of a declaration for atof causes the compiler to assume atof returns an int which it in term tries to convert to a double and assign to foo. In C this would be equivalent to something like: foo = (double)((int)atof("1.345")); Steve To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message