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 066961F47C for ; Sat, 28 Jan 2023 02:28:34 +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=QPtYX2pv; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pLax3-0000Vy-9E; Fri, 27 Jan 2023 21:28:22 -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 1pLawz-0000VZ-Bo for bug-gnulib@gnu.org; Fri, 27 Jan 2023 21:28:17 -0500 Received: from mo4-p00-ob.smtp.rzone.de ([81.169.146.219]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pLaww-0005cb-Ju for bug-gnulib@gnu.org; Fri, 27 Jan 2023 21:28:16 -0500 ARC-Seal: i=1; a=rsa-sha256; t=1674872891; cv=none; d=strato.com; s=strato-dkim-0002; b=hy96BqDb9WVLK2kwgP46ofteZWXm/S3HgNP1Lb34pGbYJUN3bbx8r8FtyFYtlPr/YZ 5AqLBkXeNXFIoCY4wiygJmfYktr8p7gxdAnEYpSPgopcIK0iuQMpP04+AEIQkKMHuyKH LjA+mewowqVbjDpypuGGe84kLPjpBCm3jTj35eMXMf7SWVhBN6PgPCupwG4qYRSIrYLQ oV8JY/drFRY9luDhEKjaGMKoAydfWKx8E5069wCor306mzRFmpR+HligjSSaIBDIyTQY vp8cZZ3khPHbZmwHeOqONxlFAzrIpdPUWuQAEI2qfiEtg3WlBz6Nrx3wvHQLsDQ6o6SZ TQgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; t=1674872891; s=strato-dkim-0002; d=strato.com; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=NzHKPDpMApm1KSe6Fm+Tj1smf4kd2awzeTv4gn30h/U=; b=j9s6KDjroTDbY+VpZto/EgjSTxzldf5m034Z3lYifMtJhvbSV6PgRiRzOY+e/da8Ny szWM5S4YeCgVK8o6YI6So9X5W3Pr1+I0QdDoVWCzNqfRxDAj0MANctLnCvO8+Ztxlxod Ow3tzCMTS+vIeQFDXpFPHwtmLO8Q4UiUVAcuhecrs4e4qsSFeEPC9Ucb+/YWqQ6t8lTy wFXNf9keD6uxRMJqeAtFg2PtDo1XvsFCZ9jt6TtXKm8jQVAUQGflQkSgqZrLPp8aw7NL t3uof8qcpoBgqT4sGTIpiX5Ka27+NhBWtF3yfpznYHhemWdmItYtE6REisfntjGonV4G ylSA== 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=1674872891; s=strato-dkim-0002; d=clisp.org; h=Message-ID:Date:Subject:To:From:Cc:Date:From:Subject:Sender; bh=NzHKPDpMApm1KSe6Fm+Tj1smf4kd2awzeTv4gn30h/U=; b=QPtYX2pv53n75/lF43N5xKJjEkHF04jpTLQXHh0YGaBu2/Gx710xvf0GJ+JpDJDM64 JXJWX/tCAs5tSkASjz/mjFiqPHKYsIiT7YzivgRLOi0BYq8IiTE2C5BI8hrECBhodZuA jq/TQwsI8cec0/NwtCMOgdM5j1gfAra9/3lv9RrTDgkG3ueGBnnGwggXrIiFZQ8JPTza E0NKf6kGRG+G8afwmTGzvF3AknDkNNFhSXQaXhE6witE74GF+eNmNqjh8JkLY0qm1Tz+ cNUn16ws1t3xJWQ+vZwijMkJAQ2S3GvDOTX2TEx9DCAv396L6BevO+L8Z3KOtCL8WtNx yzlw== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH0WWb0LN8XZoH94zq68+3cfpPDjvwA7022TV+YfjovfFy3RIl4" Received: from nimes.localnet by smtp.strato.de (RZmta 49.2.2 AUTH) with ESMTPSA id 098542z0S2SBMIv (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits)) (Client did not present a certificate); Sat, 28 Jan 2023 03:28:11 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Subject: alignasof: Ensure a correct _Alignof with older versions of GCC, clang Date: Sat, 28 Jan 2023 03:28:10 +0100 Message-ID: <12256368.OGSbbv5N1J@nimes> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Received-SPF: none client-ip=81.169.146.219; envelope-from=bruno@clisp.org; helo=mo4-p00-ob.smtp.rzone.de X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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 On FreeBSD 11.0/x86 and FreeBSD 12.0/x86 I now see these compilation errors: ../../gltests/test-alignasof.c:56:1: error: static_assert failed "static assertion failed" CHECK_STATIC (int64_t); ^~~~~~~~~~~~~~~~~~~~~~ ../../gltests/test-alignasof.c:45:3: note: expanded from macro 'CHECK_STATIC' static_assert (alignof (type) == offsetof (type##_helper, slot2)); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/assert.h:73:23: note: expanded from macro 'static_assert' #define static_assert _Static_assert ^ ../gllib/assert.h:256:7: note: expanded from macro '_Static_assert' _GL_STATIC_ASSERT (__VA_ARGS__, "static assertion failed", -) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/assert.h:241:48: note: expanded from macro '_GL_STATIC_ASSERT' # define _GL_STATIC_ASSERT(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) ^ ~ ../../gltests/test-alignasof.c:59:1: error: static_assert failed "static assertion failed" CHECK_STATIC (double); ^~~~~~~~~~~~~~~~~~~~~ ../../gltests/test-alignasof.c:45:3: note: expanded from macro 'CHECK_STATIC' static_assert (alignof (type) == offsetof (type##_helper, slot2)); \ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/assert.h:73:23: note: expanded from macro 'static_assert' #define static_assert _Static_assert ^ ../gllib/assert.h:256:7: note: expanded from macro '_Static_assert' _GL_STATIC_ASSERT (__VA_ARGS__, "static assertion failed", -) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../gllib/assert.h:241:48: note: expanded from macro '_GL_STATIC_ASSERT' # define _GL_STATIC_ASSERT(R, DIAGNOSTIC, ...) _Static_assert (R, DIAGNOSTIC) ^ ~ 2 errors generated. and similarly in test-alignof.c. The reason is that * On these platforms, clang version 3.8.0 and 6.0.1 is used, respectively. * These old GCC and clang versions have a bug in _Alignof, that we work around since 2015-10-18. * But since 2023-01-15, the workaround exists only in one place: in config.h. No longer in gnulib's generated . * There, in config.h, it is not applied if the system has a file. This patch fixes it. 2023-01-27 Bruno Haible alignasof: Ensure a correct _Alignof with older versions of GCC, clang. * m4/stdalign.m4 (gl_ALIGNASOF): Apply the workaround for wrong _Alignof in GCC < 4.9 and clang < 8.0.0 also when the system has . diff --git a/ChangeLog b/ChangeLog index 34514a6d9a..8b26652f22 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2023-01-27 Bruno Haible + + alignasof: Ensure a correct _Alignof (regression 2023-01-15). + * m4/stdalign.m4 (gl_ALIGNASOF): Apply the workaround for wrong _Alignof + in GCC < 4.9 and clang < 8.0.0 also when the system has . + 2023-01-27 Bruno Haible stdalign: Ensure alignof is defined on FreeBSD (regression 2023-01-15). diff --git a/m4/stdalign.m4 b/m4/stdalign.m4 index 3e83a2ca58..bfb08027b2 100644 --- a/m4/stdalign.m4 +++ b/m4/stdalign.m4 @@ -71,7 +71,8 @@ AC_DEFUN([gl_ALIGNASOF], [#if !defined HAVE_C_ALIGNASOF && __cplusplus < 201103 && !defined alignof # if HAVE_STDALIGN_H # include -# else +# endif + /* ISO C23 alignas and alignof for platforms that lack it. References: @@ -99,30 +100,32 @@ AC_DEFUN([gl_ALIGNASOF], /* GCC releases before GCC 4.9 had a bug in _Alignof. See GCC bug 52023 . clang versions < 8.0.0 have the same bug. */ -# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ - || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ - && !defined __clang__) \ - || (defined __clang__ && __clang_major__ < 8)) -# ifdef __cplusplus -# if (201103 <= __cplusplus || defined _MSC_VER) -# define _Alignof(type) alignof (type) -# else - template struct __alignof_helper { char __a; __t __b; }; -# define _Alignof(type) offsetof (__alignof_helper, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 -# endif +# if (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 \ + || (defined __GNUC__ && __GNUC__ < 4 + (__GNUC_MINOR__ < 9) \ + && !defined __clang__) \ + || (defined __clang__ && __clang_major__ < 8)) +# undef/**/_Alignof +# ifdef __cplusplus +# if (201103 <= __cplusplus || defined _MSC_VER) +# define _Alignof(type) alignof (type) # else -# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ -# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) -# else -# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) -# define _GL_STDALIGN_NEEDS_STDDEF 1 -# endif + template struct __alignof_helper { char __a; __t __b; }; +# define _Alignof(type) offsetof (__alignof_helper, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 +# endif +# else +# if (defined __GNUC__ && 4 <= __GNUC__) || defined __clang__ +# define _Alignof(type) __builtin_offsetof (struct { char __a; type __b; }, __b) +# else +# define _Alignof(type) offsetof (struct { char __a; type __b; }, __b) +# define _GL_STDALIGN_NEEDS_STDDEF 1 # endif # endif -# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) -# define alignof _Alignof -# endif +# endif +# if ! (defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER)) +# undef/**/alignof +# define alignof _Alignof +# endif /* alignas (A), also known as _Alignas (A), aligns a variable or type to the alignment A, where A is an integer constant expression. For @@ -148,6 +151,7 @@ AC_DEFUN([gl_ALIGNASOF], - alignas (TYPE) is equivalent to alignas (alignof (TYPE)). */ +# if !HAVE_STDALIGN_H # if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112 # if defined __cplusplus && (201103 <= __cplusplus || defined _MSC_VER) # define _Alignas(a) alignas (a) @@ -169,9 +173,10 @@ AC_DEFUN([gl_ALIGNASOF], || (defined __STDC_VERSION__ && 201112 <= __STDC_VERSION__)) # define alignas _Alignas # endif -# if _GL_STDALIGN_NEEDS_STDDEF -# include -# endif +# endif + +# if _GL_STDALIGN_NEEDS_STDDEF +# include # endif #endif]) ])