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=-4.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, 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 8E3A81F47C for ; Sat, 14 Jan 2023 23:28:13 +0000 (UTC) Authentication-Results: dcvr.yhbt.net; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=I/COS42O; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGpwH-0006Ck-No; Sat, 14 Jan 2023 18:27:53 -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 1pGpwG-0006CQ-3A for bug-gnulib@gnu.org; Sat, 14 Jan 2023 18:27:52 -0500 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pGpwE-0003ZO-Av for bug-gnulib@gnu.org; Sat, 14 Jan 2023 18:27:51 -0500 Received: by mail-pj1-x102b.google.com with SMTP id o7-20020a17090a0a0700b00226c9b82c3aso27833377pjo.3 for ; Sat, 14 Jan 2023 15:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=6bG5saoK+kSHd3TxcgDLNK6Hlu7TRAtRlC/ewp3iHFY=; b=I/COS42Od+L8yZ0lYb5168jcIA4UOxyiWhw2nNMTrXwgKVkuIE+9Cl0DQhjOtSJlgy Ik04bazmYJKId7pXIqPqLlPkX1AU8/vgFuCUJUQBsGAvKLpzKL0ePkExAaA2t9RxahND 1eBxVsprAFD1E04Z2X3Zj4+jW0Llw7z7B3fW50Qg5OGJl40rSUfKgXQY0PB1h9DkBVlO tk9CMaZbX33nmMBv8jO/FRY4O2i9DLVRCPkFpxeNAX07yyzuRoEMoM9WBAPo5E/XVNon m0y+u6RuESFcYXdpMydRzEdYoGIYU3JFqe7aaC//sHiqXVEI0OEW0Kgw2TqCPpxKAvus 0FUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=6bG5saoK+kSHd3TxcgDLNK6Hlu7TRAtRlC/ewp3iHFY=; b=e0eGp+wKNtzXY7WK/y5xhYWwnwsMoN10uGTxMqffer/ceze1BlX3Nrmz1Bf0EGHzZJ vi2PRO0yEFNlcz+keC0FW6LAEhRG7c/TrNs3S4g0DfJJ6dhdPk9IPXIqtKKpEgIXTfIa pxIuOuCnaXSIPnbcxytDquWDhiEm5lebJyTPHlNsHeO0GsKmfSRhBXB4T3dFuOVIk4bX j7OmD4J5cgaTsuHrHnfHWOvAGf0l/zWa0AKb8g8LgI4OJIeKcY5F5pt4DQ8LYigRD0hW ri4AXXfpGWlQKmjZt6XO0/nGPNxicHrgkZ9EEVtmSBOrnkKuP85av5hX8YXMGY7Lp6Ee uhcA== X-Gm-Message-State: AFqh2koztH6hJLGMjbPjXkj+0ozgf4xfAi/6JELylFGqXT35jb4jrC0Z LaJGvNzUWPK2qsVQM6s68Ntm+/yccUQAcg== X-Google-Smtp-Source: AMrXdXuI4rld6B6479aXcwdpkCHbOOH/92OtBJrnpkKoP86ymH6ddbMobG8wIAS8W4gVTbB1EhPYPg== X-Received: by 2002:a17:903:2649:b0:18d:61f6:e254 with SMTP id je9-20020a170903264900b0018d61f6e254mr15362078plb.33.1673738867913; Sat, 14 Jan 2023 15:27:47 -0800 (PST) Received: from apollo.hsd1.ca.comcast.net ([2601:646:9181:1cf0::b940]) by smtp.gmail.com with ESMTPSA id u7-20020a17090341c700b00186c3afb49esm16385213ple.209.2023.01.14.15.27.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 14 Jan 2023 15:27:47 -0800 (PST) From: Khem Raj To: bug-gnulib@gnu.org Cc: Khem Raj Subject: [PATCH] Define alignof_slot using _Alignof when using C11 or newer Date: Sat, 14 Jan 2023 15:27:44 -0800 Message-Id: <20230114232744.215167-1-raj.khem@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::102b; envelope-from=raj.khem@gmail.com; helo=mail-pj1-x102b.google.com 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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.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 WG14 N2350 made very clear that it is an UB having type definitions within "offsetof" [1]. This patch enhances the implementation of macro alignof_slot to use builtin "_Alignof" to avoid undefined behavior on when using std=c11 or newer clang 16+ has started to flag this [2] Fixes build when using -std >= gnu11 and using clang16+ [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm [2] https://reviews.llvm.org/D133574 Signed-off-by: Khem Raj --- ChangeLog | 5 +++++ lib/alignof.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index fb467a3c14..71d7f7b7f6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2023-01-15 Khem Raj + + * lib/alignof.h (alignof_slot): Use _Alignof when using C11 or newer + standard. + 2023-01-14 Bruno Haible error, verror tests: Fix link error when the package uses libintl. diff --git a/lib/alignof.h b/lib/alignof.h index 505ad97aa4..66a9496518 100644 --- a/lib/alignof.h +++ b/lib/alignof.h @@ -28,6 +28,8 @@ #if defined __cplusplus template struct alignof_helper { char __slot1; type __slot2; }; # define alignof_slot(type) offsetof (alignof_helper, __slot2) +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus) +# define alignof_slot(type) _Alignof(type) #else # define alignof_slot(type) offsetof (struct { char __slot1; type __slot2; }, __slot2) #endif -- 2.39.0