diff mbox

[1/3] Do not use __builtin_types_compatible_p in C++ mode (bug 21930)

Message ID 20170815174501.4143-2-gftg@linux.vnet.ibm.com
State New
Headers show

Commit Message

Gabriel F. T. Gomes Aug. 15, 2017, 5:44 p.m. UTC
The logic to define isinf for float128 depends on the availability of
__builtin_types_compatible_p, which is only available in C mode,
however, the conditionals do not check for C or C++ mode.  This lead to
an error in libstdc++ configure, as reported by bug 21930.

This patch adds a conditional for C mode in the definition of isinf for
float128.  No definition is provided in C++ mode, since libstdc++
headers undefine isinf.

Tested for powerpc64le (glibc test suite and libstdc++-v3 configure).

	[BZ #21930]
	* math/math.h (isinf): Check if in C or C++ mode before using
	__builtin_types_compatible_p, since this is a C mode feature.
---
 math/math.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Joseph Myers Aug. 15, 2017, 7:56 p.m. UTC | #1
On Tue, 15 Aug 2017, Gabriel F. T. Gomes wrote:

> The logic to define isinf for float128 depends on the availability of
> __builtin_types_compatible_p, which is only available in C mode,
> however, the conditionals do not check for C or C++ mode.  This lead to
> an error in libstdc++ configure, as reported by bug 21930.
> 
> This patch adds a conditional for C mode in the definition of isinf for
> float128.  No definition is provided in C++ mode, since libstdc++
> headers undefine isinf.

OK.
Gabriel F. T. Gomes Aug. 18, 2017, 3:28 p.m. UTC | #2
On Tue, 15 Aug 2017 19:56:44 +0000
Joseph Myers <joseph@codesourcery.com> wrote:

> On Tue, 15 Aug 2017, Gabriel F. T. Gomes wrote:
> 
> > The logic to define isinf for float128 depends on the availability of
> > __builtin_types_compatible_p, which is only available in C mode,
> > however, the conditionals do not check for C or C++ mode.  This lead to
> > an error in libstdc++ configure, as reported by bug 21930.
> > 
> > This patch adds a conditional for C mode in the definition of isinf for
> > float128.  No definition is provided in C++ mode, since libstdc++
> > headers undefine isinf.  
> 
> OK.
> 

Thanks.  I pushed patches 1 and 3 in this thread.  Patch 2 still needs
more changes.
diff mbox

Patch

diff --git a/math/math.h b/math/math.h
index e21708045a..dea8dbe1ae 100644
--- a/math/math.h
+++ b/math/math.h
@@ -442,8 +442,12 @@  enum
 
 /* Return nonzero value if X is positive or negative infinity.  */
 # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
-     && !defined __SUPPORT_SNAN__
-   /* __builtin_isinf_sign is broken for float128 only before GCC 7.0.  */
+     && !defined __SUPPORT_SNAN__ && !defined __cplusplus
+   /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
+      use the helper function, __isinff128, with older compilers.  This is
+      only provided for C mode, because in C++ mode, GCC has no support
+      for __builtin_types_compatible_p (and when in C++ mode, this macro is
+      not used anyway, because libstdc++ headers undefine it).  */
 #  define isinf(x) \
     (__builtin_types_compatible_p (__typeof (x), _Float128) \
      ? __isinff128 (x) : __builtin_isinf_sign (x))