[v3,1/6] ldbl-128ibm-compat: workaround GCC 9 C++ BZ 90731
Commit Message
GCC 9 has a bug (BZ 90731) 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,
| ^~~~~~~
---
include/monetary.h | 8 ++++++++
include/printf.h | 8 ++++++++
include/stdio.h | 10 ++++++++++
include/stdlib.h | 9 +++++++++
include/wchar.h | 9 +++++++++
5 files changed, 44 insertions(+)
Comments
On 4/6/20 2:12 PM, Paul E. Murphy via Libc-alpha wrote:
> GCC 9 has a bug (BZ 90731) 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,
> | ^~~~~~~
> ---
> include/monetary.h | 8 ++++++++
> include/printf.h | 8 ++++++++
> include/stdio.h | 10 ++++++++++
> include/stdlib.h | 9 +++++++++
> include/wchar.h | 9 +++++++++
> 5 files changed, 44 insertions(+)
Ping?
On 4/15/20 9:20 AM, Paul E Murphy via Libc-alpha wrote:
>
>
> On 4/6/20 2:12 PM, Paul E. Murphy via Libc-alpha wrote:
>> GCC 9 has a bug (BZ 90731) 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,
>> | ^~~~~~~
>> ---
>> include/monetary.h | 8 ++++++++
>> include/printf.h | 8 ++++++++
>> include/stdio.h | 10 ++++++++++
>> include/stdlib.h | 9 +++++++++
>> include/wchar.h | 9 +++++++++
>> 5 files changed, 44 insertions(+)
>
> Ping?
Ping. I will commit this friday pending no additional feedback.
* Paul E. Murphy via Libc-alpha:
> GCC 9 has a bug (BZ 90731) 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.
I think GCC developers prefer “PR90731” to their bugs. This occurs
multiple times in the commit message and throughout the patch.
This change will still cause errors with -Wsystem-headers in the build
flags, right? I think we should mention this somewhere, maybe on the
release wiki?
On 4/22/20 10:11 AM, Florian Weimer wrote:
> * Paul E. Murphy via Libc-alpha:
>
>> GCC 9 has a bug (BZ 90731) 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.
>
> I think GCC developers prefer “PR90731” to their bugs. This occurs
> multiple times in the commit message and throughout the patch.
Ack. Will fix here and in the subsequent patches too.
>
> This change will still cause errors with -Wsystem-headers in the build
> flags, right? I think we should mention this somewhere, maybe on the
> release wiki?
>
Unfortunately, ppc64le glibc will fail to build with GCC 9.2.0 with this
option irrespective of this feature. Though, you are correct the
redirects will generate additional warnings when used with such toolchains.
Likewise, --disable-werror does avoid breaking things when using
-Wsystem-headers. The warnings are not fatal.
I suspect the -Wsystem-headers will cause some noise for most users with
GCC 8/9 and likely others. I can add a note, but I suspect I will need
to be granted wiki editing privileges.
* Paul E. Murphy:
> I suspect the -Wsystem-headers will cause some noise for most users with
> GCC 8/9 and likely others. I can add a note, but I suspect I will need
> to be granted wiki editing privileges.
I can try to help with that. What's your Wiki account name?
@@ -1,3 +1,11 @@
+/* Workaround BZ 90731 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>
@@ -1,5 +1,13 @@
#ifndef _PRINTF_H
+/* Workaround BZ 90731 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
@@ -2,8 +2,18 @@
# if !defined _ISOMAC && defined _IO_MTSAFE_IO
# include <stdio-lock.h>
# endif
+
+/* Workaround BZ 90731 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>
@@ -3,6 +3,15 @@
#ifndef _ISOMAC
# include <stddef.h>
#endif
+
+/* Workaround BZ 90731 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. */
@@ -1,4 +1,13 @@
#ifndef _WCHAR_H
+
+/* Workaround BZ 90731 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