From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 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 E9C1A1F4B4 for ; Thu, 14 Jan 2021 00:38:12 +0000 (UTC) Received: from localhost ([::1]:60148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kzqeR-000178-BL for normalperson@yhbt.net; Wed, 13 Jan 2021 19:38:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzqeM-00014z-LG for bug-gnulib@gnu.org; Wed, 13 Jan 2021 19:38:06 -0500 Received: from zimbra.cs.ucla.edu ([131.179.128.68]:57220) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kzqeJ-0003Kn-QN for bug-gnulib@gnu.org; Wed, 13 Jan 2021 19:38:05 -0500 Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 6E42B160054; Wed, 13 Jan 2021 16:38:00 -0800 (PST) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id VwjkWZ23fZd8; Wed, 13 Jan 2021 16:37:59 -0800 (PST) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 4F42E16008F; Wed, 13 Jan 2021 16:37:59 -0800 (PST) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id MGJeWAL0-aNI; Wed, 13 Jan 2021 16:37:59 -0800 (PST) Received: from [192.168.1.9] (cpe-23-243-218-95.socal.res.rr.com [23.243.218.95]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 1E1BB160054; Wed, 13 Jan 2021 16:37:59 -0800 (PST) To: Bruno Haible References: <87k0sixwya.fsf@lrde.epita.fr> <2634507.PNdPYx674J@omega> From: Paul Eggert Organization: UCLA Computer Science Department Subject: Re: clang++ 11 compilation issues Message-ID: <1a11d0b0-36d5-cec2-c4c3-dc6003aa22d3@cs.ucla.edu> Date: Wed, 13 Jan 2021 16:37:58 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.5.0 MIME-Version: 1.0 In-Reply-To: <2634507.PNdPYx674J@omega> Content-Type: multipart/mixed; boundary="------------63B39057C9EA354E7963D51B" Content-Language: en-US Received-SPF: pass client-ip=131.179.128.68; envelope-from=eggert@cs.ucla.edu; helo=zimbra.cs.ucla.edu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, NICE_REPLY_A=-0.001, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: bug-gnulib@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Gnulib discussion list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: bug-gnulib@gnu.org, Alexandre Duret-Lutz Errors-To: bug-gnulib-bounces+normalperson=yhbt.net@gnu.org Sender: "bug-gnulib" This is a multi-part message in MIME format. --------------63B39057C9EA354E7963D51B Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 1/12/21 12:19 PM, Bruno Haible wrote: >> Those macros check for >> __cpp_static_assert to assume something about _Static_assert, which >> seems dubious. > Paul can tell more about this one. I agree it's dubious. Also, looking over the current verify.h, it's a little complicated and I=20 doubt whether the complexity is worth it nowadays. How about if we=20 simplify the C++ case, by simply relying on __cpp_static_assert there?=20 Although this could miss opportunities for generating diagnostics via=20 older C++ compilers, I doubt whether they're worth the trouble any more. Proposed Gnulib patch attached (I haven't installed it). --------------63B39057C9EA354E7963D51B Content-Type: text/x-patch; charset=UTF-8; name="0001-verify-rely-more-on-__cpp_static_assert.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="0001-verify-rely-more-on-__cpp_static_assert.patch" =46rom ce90a689fc388c4c612861054adcb09bd3658b1c Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Wed, 13 Jan 2021 15:46:33 -0800 Subject: [PATCH] verify: rely more on __cpp_static_assert * lib/verify.h (_GL_HAVE__STATIC_ASSERT, _GL_HAVE__STATIC_ASSERT1): Simplify for the C++ case, by relying only on __cpp_static_assert. That should be good enough nowadays for C++. (_GL_HAVE_STATIC_ASSERT_CXX11, _GL_HAVE_STATIC_ASSERT_CXX17): Remove. All uses replaced by simply checking __cpp_static_assert. --- ChangeLog | 9 +++++++++ lib/verify.h | 53 ++++++++++++---------------------------------------- 2 files changed, 21 insertions(+), 41 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2123974c8..8991d6a35 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2021-01-13 Paul Eggert + + verify: simplify static_assert configuration + * lib/verify.h (_GL_HAVE__STATIC_ASSERT, _GL_HAVE__STATIC_ASSERT1): + Do not define for C++. This should be good enough nowadays, + since recent-enough C++ compilers have static_assert. + (_GL_HAVE_STATIC_ASSERT_CXX11, _GL_HAVE_STATIC_ASSERT_CXX17): + Remove. All uses replaced by simply checking __cpp_static_assert. + 2021-01-13 Simon Josefsson =20 lib-msvc-compat: Update libtool usage recommendation. diff --git a/lib/verify.h b/lib/verify.h index a9e75890f..a62a47087 100644 --- a/lib/verify.h +++ b/lib/verify.h @@ -22,52 +22,23 @@ =20 =20 /* Define _GL_HAVE__STATIC_ASSERT to 1 if _Static_assert (R, DIAGNOSTIC)= - works as per C11. This is supported by GCC 4.6.0 and later, in C - mode, and by clang (also in C++ mode). + works as per C11. This is supported by GCC 4.6.0+ and by clang 4+. =20 Define _GL_HAVE__STATIC_ASSERT1 to 1 if _Static_assert (R) works as - per C2X. This is supported by GCC 9.1 and later, and by clang in - C++1z mode. - - Define _GL_HAVE_STATIC_ASSERT_CXX11 if static_assert (R, DIAGNOSTIC) - works as per C++11. This is supported by GCC 6.1 and later, and by - clang in C++11 mode. - - Define _GL_HAVE_STATIC_ASSERT_CXX17 if static_assert (R) works as per= - C++17. This is supported by GCC 9.1 and later, and by clang in - C++1z mode. + per C2X. This is supported by GCC 9.1+. =20 Support compilers claiming conformance to the relevant standard, and also support GCC when not pedantic. If we were willing to slow 'configure' down we could also use it with other compilers, but since this affects only the quality of diagnostics, why bother? */ -#ifndef __cplusplus -# if (201112L <=3D __STDC_VERSION__ \ - || (!defined __STRICT_ANSI__ \ - && (4 < __GNUC__ + (6 <=3D __GNUC_MINOR__) || 4 <=3D __clang_m= ajor__))) -# define _GL_HAVE__STATIC_ASSERT 1 -# endif -# if (202000L <=3D __STDC_VERSION__ \ - || (!defined __STRICT_ANSI__ && 9 <=3D __GNUC__)) -# define _GL_HAVE__STATIC_ASSERT1 1 -# endif -#else -# if 4 <=3D __clang_major__ -# define _GL_HAVE__STATIC_ASSERT 1 -# endif -# if 4 <=3D __clang_major__ && 201411 <=3D __cpp_static_assert -# define _GL_HAVE__STATIC_ASSERT1 1 -# endif -# if 201103L <=3D __cplusplus \ - || 6 <=3D __GNUC__ \ - || (4 <=3D __clang_major__ && 200410 <=3D __cpp_static_assert) -# define _GL_HAVE_STATIC_ASSERT_CXX11 1 -# endif -# if 201703L <=3D __cplusplus \ - || 9 <=3D __GNUC__ \ - || (4 <=3D __clang_major__ && 201411 <=3D __cpp_static_assert) -# define _GL_HAVE_STATIC_ASSERT_CXX17 1 -# endif +#if (201112L <=3D __STDC_VERSION__ \ + || (!defined __STRICT_ANSI__ \ + && (4 < __GNUC__ + (6 <=3D __GNUC_MINOR__) || 4 <=3D __clang_ma= jor__))) +# define _GL_HAVE__STATIC_ASSERT 1 +#endif +#if (202000L <=3D __STDC_VERSION__ \ + || (!defined __STRICT_ANSI__ && 9 <=3D __GNUC__)) +# define _GL_HAVE__STATIC_ASSERT1 1 #endif =20 /* FreeBSD 9.1 , included by and lots of other @@ -234,7 +205,7 @@ template Unfortunately, unlike C11, this implementation must appear as an ordinary declaration, and cannot appear inside struct { ... }. */ =20 -#if defined _GL_HAVE_STATIC_ASSERT_CXX11 +#if 200410 <=3D __cpp_static_assert # define _GL_VERIFY(R, DIAGNOSTIC, ...) static_assert (R, DIAGNOSTIC) #elif defined _GL_HAVE__STATIC_ASSERT # define _GL_VERIFY(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) @@ -250,7 +221,7 @@ template # define _Static_assert(...) \ _GL_VERIFY (__VA_ARGS__, "static assertion failed", -) # endif -# if !defined _GL_HAVE_STATIC_ASSERT_CXX17 && !defined static_assert +# if __cpp_static_assert < 201411 && !defined static_assert # define static_assert _Static_assert /* C11 requires this #define. */= # endif #endif --=20 2.27.0 --------------63B39057C9EA354E7963D51B--