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: Tue, 19 Oct 2021 17:02:16 +0000 (GMT) [thread overview] Message-ID: <20211019170216.27E533857C64@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3a06b7d1590ae0d220d5898c7b34f91aafad1960 commit 3a06b7d1590ae0d220d5898c7b34f91aafad1960 Author: Fangrui Song <maskray@google.com> Date: Thu Oct 7 17:45:16 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 -O0 errors: ../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), -O2 -Wpedantic has a similar warning. See https://gcc.gnu.org/PR102502 for GCC's inconsistency. Use enum which is guaranteed to be a constant expression. This also makes the file compilable with 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-19 17:02 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-10-19 17:02 Fangrui Song [this message] -- strict thread matches above, loose matches on Subject: below -- 2021-10-11 18:16 Fangrui Song 2021-10-10 23:34 Fangrui Song 2021-10-10 23:13 Fangrui Song 2021-10-08 1:44 Fangrui Song 2021-10-07 20:14 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=20211019170216.27E533857C64@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).