From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb34.google.com (mail-yb1-xb34.google.com [IPv6:2607:f8b0:4864:20::b34]) by sourceware.org (Postfix) with ESMTPS id 017E63858408 for ; Mon, 27 Sep 2021 17:18:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 017E63858408 Received: by mail-yb1-xb34.google.com with SMTP id m132so5530961ybf.8 for ; Mon, 27 Sep 2021 10:18:09 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=4lWCNfV/hupZg9mXABuP37zLCQhHv6fPYMxu/WL0QAA=; b=BcyLig4bzdJkZfkVLfzU6GbwTKOdCaEaebj8m530OJJDnocRY93pXQzM+vI6jdloig Njx9pp1a4SFDulBHYyswhdLfSpb5ojANs39Lv60TVB4yEERZ2aHGNtt7soHFzcmI0yMh fjtyUQrqcKa/LOhlxvEVDZmDRHWFa+3IDGauWvPkthNYxeQIzYgVk5L3mrcDmJFlJ3er geKjc9p9MLA5+qNftdGY/gWDk4l6dTIDHHsZBbrNyu0vlQjdnU/XzBPJi51II7aqhh7v eCgUAacOV150sFE3GCIKJQqulwBXWLgUbFjEVsGIAkjshoaisQe+6DUy991SRX3tQXd/ 3XuQ== X-Gm-Message-State: AOAM531MD6zPQIaxHWck/OI+koDVHIEZxT0pbpJbq93PhuEBPKAuYqCF iaT4v1Cvoqk+be5lDVVT2bFi62DUqxjdUiQnlEASAA== X-Google-Smtp-Source: ABdhPJzKKpnPdLsMpvuO4N2IcgnsQPuenx7oG257uk3B+TUiGlnm3ia8hjonQOJ8KBJ6EfedAKmzIvTCwIHa95Pa41o= X-Received: by 2002:a25:5e42:: with SMTP id s63mr1144104ybb.308.1632763089393; Mon, 27 Sep 2021 10:18:09 -0700 (PDT) MIME-Version: 1.0 References: <20210926223619.552849-1-maskray@google.com> <20210926232518.rrdffvkdhftkj4tf@google.com> <87v92mgo8a.fsf@oldenburg.str.redhat.com> In-Reply-To: <87v92mgo8a.fsf@oldenburg.str.redhat.com> From: =?UTF-8?B?RsSBbmctcnXDrCBTw7JuZw==?= Date: Mon, 27 Sep 2021 10:17:58 -0700 Message-ID: Subject: Re: [PATCH] linux: Fix a non-constant expression in _Static_assert To: Florian Weimer , Paul Eggert Cc: Fangrui Song via Libc-alpha , Adhemerval Zanella Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.9 required=5.0 tests=BAYES_00, DKIMWL_WL_MED, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH, KAM_INFOUSMEBIZ, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 27 Sep 2021 17:18:11 -0000 On Mon, Sep 27, 2021 at 6:09 AM Florian Weimer wrote: > > * Fangrui Song via Libc-alpha: > > > The description needs some adjustment > > https://www.iso-9899.info/n1570.html#6.6p10 > > > > 10 An implementation may accept other forms of constant expressions. > > Yeah, but the change itself is clearly correct. Thanks. > > Florian > Ugh, you may have missed my point that GCC -O0 and -O2 are not consistent on whether a `const int` operand can be used in a constant expression. Updated description: --- linux: Fix a non-constant expression in _Static_assert According to C11 6.6p6, `const int` as an operand may not make up a constant expression. GCC's -O0 and -O2 optimization levels are not consistent on whether this operand can be used in a constant expression: ../sysdeps/unix/sysv/linux/opendir.c:107:19: error: static_assert expression is not an integral constant expression _Static_assert (allocation_size >= sizeof (struct dirent64), Use enum which is guaranteed to be a constant expression. This fixes an error when compiling with GCC -O0 and Clang. Fixes: 4b962c9e859de23b461d61f860dbd3f21311e83a ("linux: Simplify opendir buffer allocation")