Date: Wed, 10 Jul 2013 18:33:15 +0200 From: "O. Hartmann" <ohartman@zedat.fu-berlin.de> To: David Chisnall <theraven@FreeBSD.org> Cc: FreeBSD CURRENT <freebsd-current@FreeBSD.org>, freebsd-toolchain@FreeBSD.org 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: <CD51F125-AE9E-4461-916D-CF583002B47D@FreeBSD.org> References: <20130710155809.0f589c22@thor.walstatt.dyndns.org> <CD51F125-AE9E-4461-916D-CF583002B47D@FreeBSD.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <theraven@FreeBSD.org> wrote: > Hi, >=20 > On 10 Jul 2013, at 14:58, "O. Hartmann" <ohartman@zedat.fu-berlin.de> > 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<real_t, size>') > > 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 <class _A1> > _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 <cmath>? 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 <cmath> 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 <iostream> #include <typeinfo> #include <cmath> 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130710183315.725dfde0>