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.2 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 C49BA1F47C for ; Sun, 15 Jan 2023 01:20:43 +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=QZ+rCTPK; dkim-atps=neutral Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pGrhM-0006yP-2V; Sat, 14 Jan 2023 20:20:36 -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 1pGrhL-0006xz-1c for bug-gnulib@gnu.org; Sat, 14 Jan 2023 20:20:35 -0500 Received: from mail-oi1-x22c.google.com ([2607:f8b0:4864:20::22c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pGrhJ-00022J-B5 for bug-gnulib@gnu.org; Sat, 14 Jan 2023 20:20:34 -0500 Received: by mail-oi1-x22c.google.com with SMTP id d188so9456514oia.3 for ; Sat, 14 Jan 2023 17:20:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=3OywRi1tVKVDwzLKI9xNSP3lvbYLSRm3tvK8RlGPsYA=; b=QZ+rCTPK78kfCDmtd6vJ/wavQUjGj+S6UaokulLu0Z0q1W3+KqqkMsLg/FVUL8opFA c2BSDEUsiM9nZsM1gr9LSBQsOxqlY4LszG3pyOtfeLFlnL12T7ccj5A5nTnj+Nan+a7j rjVPOZHFrJVpwYQ7ZBUYJbar3c2G2oNOEvDajsanszxDTl3ulb4DbhHnXlHXHLPKAm4C UQM7xX8FkxgqYprCk3/hSo0XsBiSs6C9cFJPhh21BKaqd+Ggoe4HcfJ38Xu1NFSwFRy+ hCIJrMKv8wxBf0MpmoAM3KwPBkXYMFqxVeRMS2a1oE8JlL8ZuwUw6qrjH6Tt0CWwJdqO fDsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3OywRi1tVKVDwzLKI9xNSP3lvbYLSRm3tvK8RlGPsYA=; b=AHj3sGmgu2fcYaO44AEuEHGwEjFSCTT8It5yhMqMwJh5cRb3Becp+wtzURFPZjAnCM KEuA9db4SBTikp13Q8h68VzDN37TBOGo52YPjxRduC15QYYC6+8P4ixY1rLWjjO5LtgI ohdECiguct1R27I6KMn+qPsicQn3Y+QvDwYYV9UY/RiqkJlqfu7pYEVHLCkR2Q54QO6v 8HZgJRHbP49eYhLvskDE7f/txZBBmKnTmDS9PwKfRwFhsgi0bwRs9+mgW9/Ib60xYJBg rLdUr88MeZQYCE+h5X+8X8os5aZCXG50RCipWe7e2nyMV39YfK7H8ujmjhFugYooQ4Fg wyDw== X-Gm-Message-State: AFqh2kpeU2pddYkW1mWyGD5AMRAS7xlmpCjwTZtTj8NhDnpWk5YOxQWw v/67Nhd9j24/Ve/SNMS+BsUSjo1BWJbexVQOkAwAJ7cWSwDeOg== X-Google-Smtp-Source: AMrXdXs5nJcUrppSi36smDFRQ6TD2C2a7QEaSZOFyXgwNfwQ9WBHbLLhoPKXm1QId9ei5p9VFlymDRs6tq8JardoSDk= X-Received: by 2002:a05:6808:7c1:b0:364:bd84:ca34 with SMTP id f1-20020a05680807c100b00364bd84ca34mr306072oij.262.1673745631736; Sat, 14 Jan 2023 17:20:31 -0800 (PST) MIME-Version: 1.0 References: <20230114232744.215167-1-raj.khem@gmail.com> <4385269.dumfJixkPq@nimes> In-Reply-To: <4385269.dumfJixkPq@nimes> From: Khem Raj Date: Sat, 14 Jan 2023 17:20:05 -0800 Message-ID: Subject: Re: [PATCH] Define alignof_slot using _Alignof when using C11 or newer To: Bruno Haible Cc: bug-gnulib@gnu.org Content-Type: text/plain; charset="UTF-8" Received-SPF: pass client-ip=2607:f8b0:4864:20::22c; envelope-from=raj.khem@gmail.com; helo=mail-oi1-x22c.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 On Sat, Jan 14, 2023 at 4:17 PM Bruno Haible wrote: > > Khem Raj wrote: > > [2] https://reviews.llvm.org/D133574 > > Thanks for the heads-up. > > > WG14 N2350 made very clear that it is an UB having type definitions > > within "offsetof" [1]. > > [1] https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2350.htm > > This document is not normative; it is merely a discussion document. > > What's (quasi) normative is > > * n3047.pdf = C23, which says in 7.21.(3) > "If the specified type defines a new type or if the specified member is > a bit-field, the behavior is undefined." > > * n2176.pdf = C18, which in 7.19.(3) merely says > "If the specified member is a bit-field, the behavior is undefined." > > So, only C23 and higher require to avoid offsetof with a new type. > > Since gnulib/lib/stdalign.h mentions an _Alignof bug in older versions of > GCC and clang and some of these older versions (e.g. GCC 4.8.5) support C11, > it is better to enable the workaround only for C23 and higher, not for > C11 and higher. > I think if its enabled only for c2x and newer, clang will still errors out for __STDC_VERSION__= 201710L I have sent out a patch which replicates the logic from gnulib/lib/stdalign.h.in which should address this as well. > > +#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L && !defined(__cplusplus) > > The '!defined(__cplusplus)' part is redundant here. > right. Dropped in v2. > Bruno > > >