From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 4F1433858D20 for ; Fri, 27 Jan 2023 09:29:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 4F1433858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1674811797; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=5lGT3wbX9ere8JmhB7u6/8In5T5JFsaScpk80E9+Vgk=; b=HbJ7LH1/cwykk8jxW8LCsqryFKBrasxZsSop4kyIIywJ9rYWMAGLAyx5Cer26tGEn+i+90 ylVsKLzsLO+oLNqWaU78TVPhYDD1MbUR/WyeoPglEY7TfrnBmtAy0xh3+J84BfjD8qiucI +xJOggYNEBblwunbSjFik84I9l+PACo= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-iSMqwafhMCG4_v6-X8YaXw-1; Fri, 27 Jan 2023 04:29:49 -0500 X-MC-Unique: iSMqwafhMCG4_v6-X8YaXw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B7DFB800B30; Fri, 27 Jan 2023 09:29:48 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.223]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70E152026D4B; Fri, 27 Jan 2023 09:29:48 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 30R9TkTs681981 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 27 Jan 2023 10:29:46 +0100 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 30R9TjfE681980; Fri, 27 Jan 2023 10:29:45 +0100 Date: Fri, 27 Jan 2023 10:29:45 +0100 From: Jakub Jelinek To: Jonathan Wakely Cc: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] libstdc++: Fix up FAIL in 17_intro/names.cc on glibc < 2.19 [PR108568] Message-ID: Reply-To: Jakub Jelinek MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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 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 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() +#include +#if __GLIBC__ == 2 && __GLIBC_MINOR__ < 19 // Glibc defines this prior to 2.19 #undef __unused #endif #endif +#endif #if __has_include() // newlib's defines these as macros. Jakub