From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS22989 209.51.188.0/24 X-Spam-Status: No, score=-3.7 required=3.0 tests=AWL,BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 0C8AA1F5A0 for ; Sat, 4 Feb 2023 16:08:40 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=clisp.org header.i=@clisp.org header.a=rsa-sha256 header.s=strato-dkim-0002 header.b=VZcevJq3; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pOL5b-00052k-Qr; Sat, 04 Feb 2023 11:08:31 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5Z-00052G-KU for bug-gnulib@gnu.org; Sat, 04 Feb 2023 11:08:29 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.162]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pOL5X-0006sJ-E8 for bug-gnulib@gnu.org; Sat, 04 Feb 2023 11:08:29 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1675526904; cv=none; d=strato.com; s=strato-dkim-0002; b=fThZ2fB9IG2kntKBaUAfHLqWoUQbPEY5D3jYONyPM7R1cYKe9L1NhOKiTeTws0NJEZ uJXJ0BGPxuViTz3dYRxG6UqpwDrFcewBxi85vNrETtooaEXyaww33xSN9p7gTRINvmeZ a3dfGYH23BJM0xclPRPbFPHmcZdAfjzeOqfxz3rTK1bq5eaAh5LYcNG5JBKjKBlxfRkK zM8gx+Dx2UUrv8GqUiQEC0V/4ZJYCWNNy7HOhX8BtAoHEaqLyNYrxybYCLFI/17M2CEY HbCyZNVKR1F8L9BBGWqj2nJ7c5E1okDyp17hmj4CdLR0uGM3VoMdMX6HPYVTJekXxQsn RSWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1675526904; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=ipMMcN4A234qJS4/o8cgbRfTyK0ZuOmevHZAo+Q3u4s=; b=JAUMFFritAYxyvKIsOZerlR9MkuilDJ89JclCzJH6InSFuzGBZeMmQKdxDbou7uxhP v1r9C9+vPtuLgal9JJN1Ghqg6KeBdeb5FdEa7R+0tEzdcygqYRJxE7+ucdA4X3bNgv/l ewm0khGYvk1kVjSmslHqWXGlZbnJsytA7IJg+Y3+w8BlpCRIC8zzdGjNADMHjN4BivYM 1hkZmllDn0mQ5menxU4grKdk7al+hEUA+RK6awYBn95HWFnRP79h5h8WRiWAJCDi2kGQ XI4pQ5xqtok4W6E/5psKF7e41dREdSUmwnmlYImPbTY/HKvR0+V8Nuh7I1VW2oFu9hIG VnPw== ARC-Authentication-Results: i=1; strato.com; arc=none; dkim=none X-RZG-CLASS-ID: mo00 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1675526904; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=ipMMcN4A234qJS4/o8cgbRfTyK0ZuOmevHZAo+Q3u4s=; b=VZcevJq3fZqhRTHd/P4TQSHgLqF04ximpq7UDfRh48HCcINXkS90B6bjx3pg1abdW/ QJ+aZEAgehnwAGp6hOYXwBRSL+4yevKwhxRO/5CBCnae8BGnM26MRC5sTGj01qk6K2Gp IvJay/lYc7R1xBC4x22ACdtyQ220xE9ndHYXVfYBcqts0nIaB2AxcHjWfi3Bo319EswO YQJwAV2ssgH2hn/M4Tzk4/4UVmSZM6ztltTCEzLZK0bso9++2A7s04aYhKSHK5ZaSmqs ZBgCFDv7zPgRFsbJbmQ2eFO9ELRwF2CWD/+e4/ZoaCtwUQKIMjAB3Ne10H6RVh16DdDQ pd4A== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPA2PGGju9CkgSBMSy6rHEf+c+mmA==" Received: from nimes.localnet by smtp.strato.de (RZmta 49.2.2 AUTH) with ESMTPSA id 098542z14G8O2GD (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Sat, 4 Feb 2023 17:08:24 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: assert-h, verify: Fix conflict with standard C++ header files on macOS Date: Sat, 04 Feb 2023 17:08:24 +0100 Message-ID: <2140319.L0AvCPtbKd@nimes> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="UTF-8" Received-SPF: none client-ip=81.169.146.162; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org After strengthening the C++ tests of , I get compilation errors on macOS 12.5, such as: In file included from ../../gltests/test-assert-h-c++.cc:26: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/u= sr/include/c++/v1/iostream:37: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/u= sr/include/c++/v1/ios:214: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/u= sr/include/c++/v1/__locale:15: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/u= sr/include/c++/v1/string:520: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/u= sr/include/c++/v1/__functional_base:26: In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/u= sr/include/c++/v1/utility:221: /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__ut= ility/pair.h:411:5: error: storage class specified for a member declaration static_assert(_Ip < 2, "Index out of bounds in std::tuple_element>"); ^ /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/__co= nfig:896:29: note: expanded from macro 'static_assert' # define static_assert(...) _Static_assert(__VA_ARGS__) ^ =2E./gllib/assert.h:256:7: note: expanded from macro '_Static_assert' _GL_STATIC_ASSERT (__VA_ARGS__, "static assertion failed", -) ^ =2E./gllib/assert.h:244:5: note: expanded from macro '_GL_STATIC_ASSERT' extern int (*_GL_GENSYM (_gl_static_assert_function) (void)) = \ ^ The problem is that _GL_STATIC_ASSERT expands to something that starts with 'extern', and that is apparently forbidden in C++ in member-declaration position. This patch fixes it. 2023-02-04 Bruno Haible assert-h, verify: Fix conflict with standard C++ header files on macOS. * lib/verify.h (_Static_assert): Don't redefine with clang =E2=89=A5 3.8.0 in C++ mode. * tests/test-assert-h-c++.cc: Also check against conflict with the standard C++ header files. * tests/test-assert-h-c++2.cc: Likewise. diff --git a/lib/verify.h b/lib/verify.h index b63cb26432..8f786af7f5 100644 =2D-- a/lib/verify.h +++ b/lib/verify.h @@ -222,7 +222,21 @@ template =20 /* _GL_STATIC_ASSERT_H is defined if this code is copied into assert.h. */ #ifdef _GL_STATIC_ASSERT_H =2D# if !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert +/* Define _Static_assert if needed. */ +/* With clang =E2=89=A5 3.8.0 in C++ mode, _Static_assert already works an= d accepts + 1 or 2 arguments. We better don't override it, because clang's standard + C++ library uses static_assert inside classes in several places, and our + replacement via _GL_VERIFY does not work in these contexts. */ +# if (defined __cplusplus && defined __clang__ \ + && (4 <=3D __clang_major__ + (8 <=3D __clang_minor__))) +# if 5 <=3D __clang_major__ +/* Avoid "warning: 'static_assert' with no message is a C++17 extension". = */ +# pragma clang diagnostic ignored "-Wc++17-extensions" +# else +/* Avoid "warning: static_assert with no message is a C++1z extension". */ +# pragma clang diagnostic ignored "-Wc++1z-extensions" +# endif +# elif !defined _GL_HAVE__STATIC_ASSERT1 && !defined _Static_assert # if !defined _MSC_VER || defined __clang__ # define _Static_assert(...) \ _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) @@ -233,6 +247,7 @@ template _GL_VERIFY ((R), "static assertion failed", -) # endif # endif +/* Define static_assert if needed. */ # if (!defined static_assert \ && __STDC_VERSION__ < 202311 \ && (!defined __cplusplus \ diff --git a/tests/test-assert-h-c++.cc b/tests/test-assert-h-c++.cc index 4fa23bfeec..6b76565633 100644 =2D-- a/tests/test-assert-h-c++.cc +++ b/tests/test-assert-h-c++.cc @@ -21,6 +21,10 @@ =20 #include =20 +/* Check against conflicts between and the C++ header files. */ +#include +#include + =20 int main () diff --git a/tests/test-assert-h-c++2.cc b/tests/test-assert-h-c++2.cc index 3c19de325c..ffd7c8cf92 100644 =2D-- a/tests/test-assert-h-c++2.cc +++ b/tests/test-assert-h-c++2.cc @@ -18,3 +18,7 @@ #include =20 #include + +/* Check against conflicts between and other C++ header files. = */ +#include +#include