public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert
@ 2021-10-19 17:02 Fangrui Song
  0 siblings, 0 replies; 6+ messages in thread
From: Fangrui Song @ 2021-10-19 17:02 UTC (permalink / raw)
  To: glibc-cvs

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)");


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert
@ 2021-10-11 18:16 Fangrui Song
  0 siblings, 0 replies; 6+ messages in thread
From: Fangrui Song @ 2021-10-11 18:16 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=f08d7730bc4edc46e7ee08e1254ee8fa727f7f48

commit f08d7730bc4edc46e7ee08e1254ee8fa727f7f48
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)");


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert
@ 2021-10-10 23:34 Fangrui Song
  0 siblings, 0 replies; 6+ messages in thread
From: Fangrui Song @ 2021-10-10 23:34 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fe40b63b4d8508dd0612a17e240b73f343cb8399

commit fe40b63b4d8508dd0612a17e240b73f343cb8399
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)");


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert
@ 2021-10-10 23:13 Fangrui Song
  0 siblings, 0 replies; 6+ messages in thread
From: Fangrui Song @ 2021-10-10 23:13 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=87cb4df467880ac2b6e4f9878c8a2c0d3a2b28bb

commit 87cb4df467880ac2b6e4f9878c8a2c0d3a2b28bb
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)");


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert
@ 2021-10-08  1:44 Fangrui Song
  0 siblings, 0 replies; 6+ messages in thread
From: Fangrui Song @ 2021-10-08  1:44 UTC (permalink / raw)
  To: glibc-cvs

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=e52e2b0a0cc410ebe2f64fb016cc94edf1df62f6

commit e52e2b0a0cc410ebe2f64fb016cc94edf1df62f6
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)");


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert
@ 2021-10-07 20:14 Fangrui Song
  0 siblings, 0 replies; 6+ messages in thread
From: Fangrui Song @ 2021-10-07 20:14 UTC (permalink / raw)
  To: glibc-cvs

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)");


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-10-19 17:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-19 17:02 [glibc/maskray/clang] linux: Fix a non-constant expression in _Static_assert Fangrui Song
  -- 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

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).