From owner-cvs-all@FreeBSD.ORG Thu Oct 30 02:23:27 2003 Return-Path: Delivered-To: cvs-all@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F0D8916A4CE; Thu, 30 Oct 2003 02:23:27 -0800 (PST) Received: from mailman.zeta.org.au (mailman.zeta.org.au [203.26.10.16]) by mx1.FreeBSD.org (Postfix) with ESMTP id 34D9C43FA3; Thu, 30 Oct 2003 02:23:25 -0800 (PST) (envelope-from bde@zeta.org.au) Received: from gamplex.bde.org (katana.zip.com.au [61.8.7.246]) by mailman.zeta.org.au (8.9.3p2/8.8.7) with ESMTP id VAA05200; Thu, 30 Oct 2003 21:23:07 +1100 Date: Thu, 30 Oct 2003 21:23:06 +1100 (EST) From: Bruce Evans X-X-Sender: bde@gamplex.bde.org To: Harti Brandt In-Reply-To: <20031030101640.G79774@beagle.fokus.fraunhofer.de> Message-ID: <20031030211635.A4570@gamplex.bde.org> References: <200310260449.h9Q4nwm9016893@repoman.freebsd.org> <20031026171515.P17272@gamplex.bde.org> <20031027152156.Y21211@gamplex.bde.org> <20031030082313.GA1649@cirb503493.alcatel.com.au> <20031030101640.G79774@beagle.fokus.fraunhofer.de> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: src-committers@freebsd.org cc: Peter Wemm cc: cvs-src@freebsd.org cc: Peter Jeremy cc: Dag-Erling =?iso-8859-1?Q?Sm=F8rgrav?= cc: cvs-all@freebsd.org Subject: Re: cvs commit: src/usr.bin/chat Makefile X-BeenThere: cvs-all@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: CVS commit messages for the entire tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 30 Oct 2003 10:23:28 -0000 On Thu, 30 Oct 2003, Harti Brandt wrote: > On Thu, 30 Oct 2003, Peter Jeremy wrote: > > PJ>On Tue, Oct 28, 2003 at 10:28:24PM +1100, Bruce Evans wrote: > PJ>>Similarly for `return (log(3));`. gcc doesn't do the log() inline, at > PJ>>least on i386's with no options, but it knows to pass 3.0 and convert > PJ>>the return value to int. > PJ> > PJ>It shouldn't. If I write: > PJ> int foo(int x) > PJ> { > PJ> return (log(x)); > PJ> } > PJ>without explicitly declaring any prototype for log(), gcc should > PJ>assume a declaration "int log(int);". Arbitrarily deciding that > PJ>the declaration should be "double log(double);" breaks K&R C and > PJ>C90 programs. > PJ> > PJ>It seems that gcc is diverging more and more from the ISO standards. > > I brought up this topic on gcc-patches. The answer was the > 5th paragraph of 7.1.3: > > "All identifiers with external linkage in any of the following subclauses > (including the future library directions) are always reserved for use as > identifiers with external linkage." > > This seems to mean that your above code snippet is not legal, because > log() impicitly gets external linkage, but is reserved by the library. Indeed. I'm not sure if the above gives undefined behaviour, but it is close to it. > Having a static log() should be ok, but will trigger that anoying gcc > shadow warning. Well, whether this makes sense or not is questionable. > Warnings should warn you not only when you invoke undefined behaviour, but > also when you do something dangerous. In > > static void > log(int i) > { > .... > } > > someone else later might remove the 'static' which then leads to undefined > behaviour. So the gcc-people think they'd rather warn here. My patch is supposed to give the warning if and only if there is no 'static' (when is not included). > You are invited to take part in the discussions on the list. ENOTIME :-). Bruce