public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Fix up FAIL in 17_intro/names.cc on glibc < 2.19 [PR108568]
@ 2023-01-27  9:29 Jakub Jelinek
  2023-01-27 10:59 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Jakub Jelinek @ 2023-01-27  9:29 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, gcc-patches

Hi!

On gcc112 which has glibc 2.17 I've noticed
FAIL: 17_intro/names.cc (test for excess errors)
FAIL: experimental/names.cc (test for excess errors)
These are because glibc < 2.19 used __unused as field member of various structs,
including mcontext_t in sys/ucontext.h on ppc64le.
This was changed in glibc with
https://gcc.gnu.org/pipermail/libc-alpha/2013-November/045766.html
names.cc even has
#ifdef __GLIBC_PREREQ
#if ! __GLIBC_PREREQ(2, 19)
// Glibc defines this prior to 2.19
#undef __unused
#endif
#endif
for it, but it doesn't work.  The reason is that __GLIBC_PREREQ is defined in
<features.h> but nothing included that header before this spot (it is included later
from bits/stdc++.h).

The following patch on Linux/Hurd conditionally includes features.h to get
the needed macros before deciding if __unused should be undefined or not.
If needed, I could use __GLIBC_PREREQ then but would need to check if it is
defined and between 1996 and 1999 it wasn't.

Tested on powerpc64le-linux with glibc 2.17 (where it fixes the
regressions), on x86_64-linux with glibc 2.35 (where it still PASSes),
plus on the latter with -E -dD on the test to verify __unused is just
defined and not undefined later on, ok for trunk?

2023-01-27  Jakub Jelinek  <jakub@redhat.com>

	PR libstdc++/108568
	* testsuite/17_intro/names.cc (__unused): For linux or GNU hurd
	include features.h if present and then check __GLIBC__ and
	__GLIBC_MINOR__ macros for glibc prior to 2.19, instead of testing
	__GLIBC_PREREQ which isn't defined yet.

--- libstdc++-v3/testsuite/17_intro/names.cc.jj	2023-01-16 23:19:06.292716661 +0100
+++ libstdc++-v3/testsuite/17_intro/names.cc	2023-01-27 10:20:20.787645823 +0100
@@ -252,12 +252,15 @@
 #undef y
 #endif
 
-#ifdef __GLIBC_PREREQ
-#if ! __GLIBC_PREREQ(2, 19)
+#if defined (__linux__) || defined (__gnu_hurd__)
+#if __has_include(<features.h>)
+#include <features.h>
+#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 19
 // Glibc defines this prior to 2.19
 #undef __unused
 #endif
 #endif
+#endif
 
 #if __has_include(<newlib.h>)
 // newlib's <sys/cdefs.h> defines these as macros.

	Jakub


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++: Fix up FAIL in 17_intro/names.cc on glibc < 2.19 [PR108568]
  2023-01-27  9:29 [PATCH] libstdc++: Fix up FAIL in 17_intro/names.cc on glibc < 2.19 [PR108568] Jakub Jelinek
@ 2023-01-27 10:59 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2023-01-27 10:59 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: libstdc++, gcc-patches

On Fri, 27 Jan 2023 at 09:29, Jakub Jelinek <jakub@redhat.com> wrote:
>
> Hi!
>
> On gcc112 which has glibc 2.17 I've noticed
> FAIL: 17_intro/names.cc (test for excess errors)
> FAIL: experimental/names.cc (test for excess errors)
> These are because glibc < 2.19 used __unused as field member of various structs,
> including mcontext_t in sys/ucontext.h on ppc64le.
> This was changed in glibc with
> https://gcc.gnu.org/pipermail/libc-alpha/2013-November/045766.html
> names.cc even has
> #ifdef __GLIBC_PREREQ
> #if ! __GLIBC_PREREQ(2, 19)
> // Glibc defines this prior to 2.19
> #undef __unused
> #endif
> #endif
> for it, but it doesn't work.  The reason is that __GLIBC_PREREQ is defined in
> <features.h> but nothing included that header before this spot (it is included later
> from bits/stdc++.h).
>
> The following patch on Linux/Hurd conditionally includes features.h to get
> the needed macros before deciding if __unused should be undefined or not.
> If needed, I could use __GLIBC_PREREQ then but would need to check if it is
> defined and between 1996 and 1999 it wasn't.
>
> Tested on powerpc64le-linux with glibc 2.17 (where it fixes the
> regressions), on x86_64-linux with glibc 2.35 (where it still PASSes),
> plus on the latter with -E -dD on the test to verify __unused is just
> defined and not undefined later on, ok for trunk?

OK, thanks.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-27 10:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-27  9:29 [PATCH] libstdc++: Fix up FAIL in 17_intro/names.cc on glibc < 2.19 [PR108568] Jakub Jelinek
2023-01-27 10:59 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).