public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Fangrui Song <maskray@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert Date: Thu, 7 Oct 2021 20:14:19 +0000 (GMT) [thread overview] Message-ID: <20211007201419.A2F8D3857800@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=8a755047999192a12316312be03051683227bf69 commit 8a755047999192a12316312be03051683227bf69 Author: Fangrui Song <maskray@google.com> Date: Mon Sep 27 10:18:08 2021 -0700 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") Diff: --- sysdeps/unix/sysv/linux/opendir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sysdeps/unix/sysv/linux/opendir.c b/sysdeps/unix/sysv/linux/opendir.c index 48f254d169..88640f44ee 100644 --- a/sysdeps/unix/sysv/linux/opendir.c +++ b/sysdeps/unix/sysv/linux/opendir.c @@ -103,7 +103,7 @@ __alloc_dir (int fd, bool close_fd, int flags, file system provides a bogus value. */ enum { max_buffer_size = 1048576 }; - const size_t allocation_size = 32768; + enum { allocation_size = 32768 }; _Static_assert (allocation_size >= sizeof (struct dirent64), "allocation_size < sizeof (struct dirent64)");
next reply other threads:[~2021-10-07 20:14 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-07 20:14 Fangrui Song [this message] 2021-10-08 1:44 Fangrui Song 2021-10-10 23:13 Fangrui Song 2021-10-10 23:34 Fangrui Song 2021-10-11 18:16 Fangrui Song 2021-10-19 17:02 Fangrui Song
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211007201419.A2F8D3857800@sourceware.org \ --to=maskray@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).