From owner-freebsd-toolchain@FreeBSD.ORG Wed Jul 10 16:33:22 2013 Return-Path: Delivered-To: freebsd-toolchain@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 32699DFE; Wed, 10 Jul 2013 16:33:22 +0000 (UTC) (envelope-from ohartman@zedat.fu-berlin.de) Received: from outpost1.zedat.fu-berlin.de (outpost1.zedat.fu-berlin.de [130.133.4.66]) by mx1.freebsd.org (Postfix) with ESMTP id E55371C58; Wed, 10 Jul 2013 16:33:21 +0000 (UTC) Received: from inpost2.zedat.fu-berlin.de ([130.133.4.69]) by outpost1.zedat.fu-berlin.de (Exim 4.80.1) with esmtp (envelope-from ) id <1UwxKS-0013Yv-Ph>; Wed, 10 Jul 2013 18:33:20 +0200 Received: from e179143131.adsl.alicedsl.de ([85.179.143.131] helo=thor.walstatt.dyndns.org) by inpost2.zedat.fu-berlin.de (Exim 4.80.1) with esmtpsa (envelope-from ) id <1UwxKS-0047Op-Kf>; Wed, 10 Jul 2013 18:33:20 +0200 Date: Wed, 10 Jul 2013 18:33:15 +0200 From: "O. Hartmann" To: David Chisnall Subject: Re: CURRENT: CLANG 3.3 and -stad=c++11 and -stdlib=libc++: isnan()/isninf() oddity Message-ID: <20130710183315.725dfde0@thor.walstatt.dyndns.org> In-Reply-To: References: <20130710155809.0f589c22@thor.walstatt.dyndns.org> Organization: FU Berlin X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.19; amd64-portbld-freebsd10.0) Mime-Version: 1.0 Content-Type: multipart/signed; micalg=PGP-SHA1; boundary="Sig_/bmcp6YFDEKEE.tdh.y_2A=c"; protocol="application/pgp-signature" X-Originating-IP: 85.179.143.131 Cc: FreeBSD CURRENT , freebsd-toolchain@FreeBSD.org X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Jul 2013 16:33:22 -0000 --Sig_/bmcp6YFDEKEE.tdh.y_2A=c Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable On Wed, 10 Jul 2013 15:22:58 +0100 David Chisnall wrote: > Hi, >=20 > On 10 Jul 2013, at 14:58, "O. Hartmann" > wrote: >=20 > >=20 > > Whe I try to compile the sources of a port in spe (devel/pocl), > > which is now out as RC6, I receive this error shown below: > >=20 > > [...] > > ../vecmathlib/pocl/../vec_sse_double1.h:451:38: error: > > conversion from 'int' to 'boolvec_t' (aka 'boolvec') > > is ambiguous boolvec_t isinf() const { return std::isinf(v); } > > ^~~~~~~~~~~~~ ../vecmathlib/pocl/../vec_sse_double1.h:75:5: note: > > candidate constructor boolvec(bvector_t x): v(x) {} > > ^ > > ../vecmathlib/pocl/../vec_sse_double1.h:76:5: note: candidate > > constructor boolvec(bool a): v(a) {} > > [...] > >=20 > > Compilation is performed on the most recent CURRENT with CLANG 3.3 > > and devel/llvm (which is obviously stuck with 3.2 for now) and > > option switches -std=3Dc++11 -stdlib=3Dlibc++. > >=20 > > As I was told, in standard C++11, isnan(), isinf() and fellows now > > should return "bool", not int as this seems obviously the case as > > the error documents and I was able to check with a small program. > >=20 > > Is this a bug in FreeBSD's implementation of libc++? Or am I doing > > something wrong? > >=20 > > I'm new to C++/C++11. > >=20 > >=20 > > Some advice or explanation could be helpful. >=20 > I believe that this is also causing some failures in the libc++ test > suite and is due to some interaction between our headers and the > libc++ headers, but I don't see where it is. >=20 > Our isnan implementation is a really ugly macro that looks like this: >=20 > #define>isnan(x) \ > ((sizeof (x) =3D=3D sizeof (float)) ? __isnanf(x) \ > : (sizeof (x) =3D=3D sizeof (double)) ? isnan(x) \ > : __isnanl(x)) >=20 >=20 > The definition in the libc++ cmath header is: >=20 > #ifdef isnan >=20 > template > _LIBCPP_ALWAYS_INLINE > bool > __libcpp_isnan(_A1 __x) _NOEXCEPT > { > return isnan(__x); > } >=20 > #undef isnan >=20 > This should work correctly. >=20 > However... >=20 > I wonder if you are including math.h instead of ? That would > show the result that you appear to be seeing, which looks like the > result of using the isnan() macro rather than the isnan() function. > If you have included then the isnan() macro will have been > defined. >=20 > David >=20 Hi David, thanks for the fast response. The code I was told to check with is this: #include #include #include int main(void) { std::cout << typeid(isnan(1.0)).name() << "\n"; } If I compile it with=20 c++ -o testme -std=3Dc++11 -stdlib=3Dlibc++ source.cc and run the binary, the result is "i" which I interpret as "INT". My OS is at=20 FreeBSD 10.0-CURRENT #4 r253138: Wed Jul 10 09:52:16 CEST 2013 Oliver --Sig_/bmcp6YFDEKEE.tdh.y_2A=c Content-Type: application/pgp-signature; name=signature.asc Content-Disposition: attachment; filename=signature.asc -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.20 (FreeBSD) iQEcBAEBAgAGBQJR3YzQAAoJEOgBcD7A/5N8ipIH/RlVZV2UXHNWv/F1Zx7kkAJK 7JFbay3QwLnoLOScXsQB9EoaXbh4ha91P1krgAccg39/esWXeBwdGRkcPe03oYkU BHHfN2RKTIERO71daPL7Y5nan3z9IYY8q0KlnMU7Xf5t/B/CMYXKyASv53s0eyNU tcblIzHHmdVwT1AfEszhBr70umS6SyIqUqlot5L3uqJF+2CTDeHjw7hj8shUN60W Jd/kC8F2zcCEC8UjwEDRDL8556e5NOIuNown6+VOhBCSAv2fiiYQe4hKgJuEfCPx hOALmY6K0uxcF/SlLfxX3fd2QzaAs8ShCiNvvi1Vz+nppCV8ytNRiwf1+xqVtLQ= =vG0c -----END PGP SIGNATURE----- --Sig_/bmcp6YFDEKEE.tdh.y_2A=c--