about summary refs log tree commit diff
path: root/include/stdlib.h
diff options
context:
space:
mode:
authorPaul E. Murphy <murphyp@linux.vnet.ibm.com>2020-03-06 09:41:03 -0600
committerPaul E. Murphy <murphyp@linux.vnet.ibm.com>2020-04-30 08:52:08 -0500
commit86005fdbf40d6fc84d84c824d75c656e7c1398e3 (patch)
treef2db5cb76956d7bcedeb4e6b721dfa18f4ce367d /include/stdlib.h
parentab54e26415ea82444a9529041427137bf27c615c (diff)
downloadglibc-86005fdbf40d6fc84d84c824d75c656e7c1398e3.tar.gz
glibc-86005fdbf40d6fc84d84c824d75c656e7c1398e3.tar.xz
glibc-86005fdbf40d6fc84d84c824d75c656e7c1398e3.zip
ldbl-128ibm-compat: workaround GCC 9 C++ PR90731
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>
Diffstat (limited to 'include/stdlib.h')
-rw-r--r--include/stdlib.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/stdlib.h b/include/stdlib.h
index 926f965f69..187a41e754 100644
--- a/include/stdlib.h
+++ b/include/stdlib.h
@@ -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.  */