Date: Thu, 11 Jul 2013 11:37:20 +0200 From: Tijl Coosemans <tijl@FreeBSD.org> To: Bruce Evans <brde@optusnet.com.au> Cc: Garrett Wollman <wollman@csail.mit.edu>, FreeBSD CURRENT <freebsd-current@FreeBSD.org>, freebsd-standards@FreeBSD.org, freebsd-toolchain@FreeBSD.org Subject: Re: CURRENT: CLANG 3.3 and -stad=c++11 and -stdlib=libc++: isnan()/isninf() oddity Message-ID: <51DE7CD0.60306@FreeBSD.org> In-Reply-To: <20130711130043.R920@besplex.bde.org> References: <20130710155809.0f589c22@thor.walstatt.dyndns.org> <CD51F125-AE9E-4461-916D-CF583002B47D@FreeBSD.org> <20130710183315.725dfde0@thor.walstatt.dyndns.org> <C8C94CF2-7D5A-471B-AD63-8E961AED6274@FreeBSD.org> <20130710203200.5359fd18@thor.walstatt.dyndns.org> <51DDC04B.6040209@FreeBSD.org> <20957.49978.73666.392417@khavrinen.csail.mit.edu> <20130711130043.R920@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
This is an OpenPGP/MIME signed message (RFC 4880 and 3156) ------enig2EUTOIBMOAOLMNPWCAKBE Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On 2013-07-11 06:21, Bruce Evans wrote: > On Wed, 10 Jul 2013, Garrett Wollman wrote: >> <<On Wed, 10 Jul 2013 22:12:59 +0200, Tijl Coosemans <tijl@freebsd.org= > said: >>> I think isnan(double) and isinf(double) in math.h should only be >>> visible if (_BSD_VISIBLE || _XSI_VISIBLE) && __ISO_C_VISIBLE < 1999. >>> For C99 and higher there should only be the isnan/isinf macros. >> >> I believe you are correct. POSIX.1-2008 (which is aligned with C99) >> consistently calls isnan() a "macro", and gives a pseudo-prototype of >> >> int isnan(real-floating x); >=20 > Almost any macro may be implemented as a function, if no conforming > program can tell the difference. It is impossible for technical reason= s > to implement isnan() as a macro (except on weird implementations where > all real-floating types are physically the same). In the FreeBSD > implementation, isnan() is a macro, but it is also a function, and > the macro expands to the function in double precision: >=20 > % #define isnan(x) \ > % ((sizeof (x) =3D=3D sizeof (float)) ? __isnanf(x) \ > % : (sizeof (x) =3D=3D sizeof (double)) ? isnan(x) \ > % : __isnanl(x)) The C99 standard says isnan is a macro. I would say that only means defined(isnan) is true. Whether that macro then expands to function calls or not is not important. > I don't see how any conforming program can access the isnan() function > directly. It is just as protected as __isnan() would be. (isnan)() > gives the function (the function prototype uses this), but conforming > programs can't do that since the function might not exist. I don't think the standard allows a function to be declared with the same= name as a standard macro (it does allow the reverse: define a macro with the same name as a standard function). I believe the following code is C99 conforming but it currently does not compile with our math.h: ------ #include <math.h> =20 int (isnan)(int a, int b, int c) { return (a + b + c); } ------ ------enig2EUTOIBMOAOLMNPWCAKBE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iF4EAREIAAYFAlHefNQACgkQfoCS2CCgtisTnwD7BfDDEcW43Z/knFNt/gk133gK oHU9NLmi8d4J9J5MIlQA/jpqMQEQHsree+HBmQmG+RWL1sBDXxit5pXk28CVamlC =faze -----END PGP SIGNATURE----- ------enig2EUTOIBMOAOLMNPWCAKBE--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?51DE7CD0.60306>