This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug math/21930] C-only gcc builtins used in <math.h> isinf
- From: "joseph at codesourcery dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Wed, 09 Aug 2017 20:22:52 +0000
- Subject: [Bug math/21930] C-only gcc builtins used in <math.h> isinf
- Auto-submitted: auto-generated
- References: <bug-21930-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=21930
--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> ---
On Wed, 9 Aug 2017, gftg at linux dot vnet.ibm.com wrote:
> > (c) Use some suitable C++ magic in place of __builtin_types_compatible_p
> > (remembering that __builtin_types_compatible_p explicitly removes type
> > qualifiers, and alternative C++ magic needs to do likewise).
>
> Since typeid also removes qualifiers implicitly
> (http://en.cppreference.com/w/cpp/language/typeid), would something in the
> lines of the following be acceptable for c++98:
>
> if (typeid(f) == typeid(float)) isinff (f)
No, because that involves a runtime comparison of type_info objects. We
want something (to go in a __MATH_TG macro definition for the "C++ and
distinct float128" case - and, similarly, an isinf definition for when C++
is combined with the present conditions for handling GCC < 7 with
_Float128) that's optimized away at compile time - something where the
conditionals are always folded to true or false. (And preferably not
depending on including any C++ headers from <math.h>; I don't know what
the rules are for such header inclusion in the C++ standard library.)
Maybe we need to understand further what cases are the problem. Various
macros may be used in that configure test, but most of them are using
type-generic built-in functions which work fine for C++ (given that
libstdc++ is not built with sNaNs enabled). The problem for the configure
test might only be the "__builtin_isinf_sign is broken for float128 only
before GCC 7.0." definition of isinf, which uses
__builtin_types_compatible_p. Separately, with the installed compiler,
most of the macros should be undefined in the libstdc++ headers, leaving
issignaling as the likely problem case using __MATH_TG (issubnormal is
defined using fpclassify; iszero has a separate C++ template definition,
to avoid problems with macros).
Possible solutions for isinf include:
* Do not use the special-case isinf definition with
__builtin_types_compatible_p for C++. It's possible this suffices to make
the configure test work (and exactly what the isinf macro does doesn't
matter when using an installed C++ compiler because the libstdc++ headers
undefine that macro, and the configure test doesn't use it with float128).
* Add a C++ variant of that definition, which would only be used for the
configure test but which still has the right semantics.
And for issignaling:
* Change __MATH_TG to have a fully functional C++ variant. float and
double can be distinguished with sizeof; it's only long double / float128
where you need a replacement for __builtin_types_compatible_p (__typeof
(TG_ARG), long double) using C++ features.
* Add template versions of issignaling for C++, like iszero.
--
You are receiving this mail because:
You are on the CC list for the bug.