]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
ldbl-128ibm-compat: workaround GCC 9 C++ PR90731
authorPaul E. Murphy <murphyp@linux.vnet.ibm.com>
Fri, 6 Mar 2020 15:41:03 +0000 (09:41 -0600)
committerPaul E. Murphy <murphyp@linux.vnet.ibm.com>
Thu, 30 Apr 2020 13:52:08 +0000 (08:52 -0500)
GCC 9 has a bug (PR90731) whereby __typeof does not correctly copy
exception specifiers[1].  Surprisingly, this can be quieted by declaring
"#pragma system_header", or if the headers are installed in a system
directory.

Work around this by using the pragma for any gcc version between
9.0 and 9.2 to ensure tests continue to compile.

[1] Example error from g++ 9.2.1:

In file included from ../include/sys/cdefs.h:3,
                 from ../include/features.h:465,
                 from ../bits/libc-header-start.h:33,
                 from ../math/math.h:27,
                 from ../include/math.h:7,
                 from test-math-isinff.cc:21:
../libio/bits/stdio-ldbl.h:25:20: error: declaration of ‘int sprintf(char*, const char*, ...)’ has a different exception specifier
   25 | __LDBL_REDIR_DECL (sprintf)
      |                    ^~~~~~~
../misc/sys/cdefs.h:461:26: note: in definition of macro ‘__LDBL_REDIR_DECL’
  461 |   extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
      |                          ^~~~
In file included from ../include/stdio.h:5,
                 from test-math-isinff.cc:22:
../libio/stdio.h:334:12: note: from previous declaration ‘int sprintf(char*, const char*, ...) throw ()’
  334 | extern int sprintf (char *__restrict __s,
      |            ^~~~~~~

Reviewed-by: Tulio Magno Quites Machado Filho <tuliom@linux.ibm.com>
include/monetary.h
include/printf.h
include/stdio.h
include/stdlib.h
include/wchar.h

index 240925e87dd2bc7e8e0d4dcc90c844edd1950f68..bddc660ce25b8e8b3c9bfac29675cb5f43302d71 100644 (file)
@@ -1,3 +1,11 @@
+/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++.  */
+#include <bits/floatn.h>
+#if defined __cplusplus && __LONG_DOUBLE_USES_FLOAT128 == 1
+# if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
+#   pragma GCC system_header
+# endif
+#endif
+
 #include <stdlib/monetary.h>
 #ifndef _ISOMAC
 #include <stdarg.h>
index d05151411915931b3d05e30bf33afba34440d2d2..bdcfd29f63a3acfc089a9a1624ce622dda275f9a 100644 (file)
@@ -1,5 +1,13 @@
 #ifndef        _PRINTF_H
 
+/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++.  */
+#include <bits/floatn.h>
+#if defined __cplusplus && __LONG_DOUBLE_USES_FLOAT128 == 1
+# if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
+#   pragma GCC system_header
+# endif
+#endif
+
 #include <stdio-common/printf.h>
 
 # ifndef _ISOMAC
index 6718af4108dd9415133c8ed6693e0a00ff36b2b4..1c09daf13a7b9cf1adf245509bb8e5c1252fb00d 100644 (file)
@@ -2,8 +2,18 @@
 # if !defined _ISOMAC && defined _IO_MTSAFE_IO
 #  include <stdio-lock.h>
 # endif
+
+/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++.  */
+# include <bits/floatn.h>
+# if defined __cplusplus && __LONG_DOUBLE_USES_FLOAT128 == 1
+#  if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
+#    pragma GCC system_header
+#  endif
+# endif
+
 # include <libio/stdio.h>
 # ifndef _ISOMAC
+
 #  define _LIBC_STDIO_H 1
 #  include <libio/libio.h>
 
index 926f965f69ff29b04f3e2554fa16d55eeadf7086..187a41e75454200d3933aabd98a4ec2914530627 100644 (file)
@@ -3,6 +3,15 @@
 #ifndef _ISOMAC
 # include <stddef.h>
 #endif
+
+/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++.  */
+#include <bits/floatn.h>
+#if defined __cplusplus && __LONG_DOUBLE_USES_FLOAT128 == 1
+# if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
+#   pragma GCC system_header
+# endif
+#endif
+
 #include <stdlib/stdlib.h>
 
 /* Now define the internal interfaces.  */
index 617906eb14cd07307b41b6fe657f89e00fcb67ea..bb49d844be4918751d8d933dbde8ef7534ad5e6d 100644 (file)
@@ -1,4 +1,13 @@
 #ifndef _WCHAR_H
+
+/* Workaround PR90731 with GCC 9 when using ldbl redirects in C++.  */
+# include <bits/floatn.h>
+# if defined __cplusplus && __LONG_DOUBLE_USES_FLOAT128 == 1
+#  if __GNUC_PREREQ (9, 0) && !__GNUC_PREREQ (9, 3)
+#   pragma GCC system_header
+#  endif
+# endif
+
 # include <wcsmbs/wchar.h>
 # ifndef _ISOMAC