Oh, I didn't know that the test harness assumes dynamic checking. I thought that since some of the other tests already use static_assert, these tests could do so too.

It's obviously no big deal to revert to dynamic checking and I installed the attached.
From a0ef641461085fece13cdf048e7882ba9eacb253 Mon Sep 17 00:00:00 2001
From: Paul Eggert <egg...@cs.ucla.edu>
Date: Tue, 18 Apr 2023 14:25:09 -0700
Subject: [PATCH] Go back to dynamic largefile, year2038 tests

Problem reported by Bruno Haible in:
https://lists.gnu.org/r/bug-gnulib/2023-04/msg00134.html
* modules/largefile-tests, modules/year2038-tests (Depends-on):
Remove assert-h.
* tests/test-largefile.c, tests/test-year2038.c:
Test dynamically, not via static_assert.
---
 ChangeLog               |  8 ++++++++
 modules/largefile-tests |  1 -
 modules/year2038-tests  |  1 -
 tests/test-largefile.c  | 27 ++++++++++++++++++---------
 tests/test-year2038.c   |  7 ++++---
 5 files changed, 30 insertions(+), 14 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 14bbfc2be7..32fbef51e3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,13 @@
 2023-04-18  Paul Eggert  <egg...@cs.ucla.edu>
 
+	Go back to dynamic largefile, year2038 tests
+	Problem reported by Bruno Haible in:
+	https://lists.gnu.org/r/bug-gnulib/2023-04/msg00134.html
+	* modules/largefile-tests, modules/year2038-tests (Depends-on):
+	Remove assert-h.
+	* tests/test-largefile.c, tests/test-year2038.c:
+	Test dynamically, not via static_assert.
+
 	doc: mention when O_* defaults to 0
 	* doc/posix-headers/fcntl.texi: Document in more detail which O_*
 	macros default to 0 in Gnulib.
diff --git a/modules/largefile-tests b/modules/largefile-tests
index 544070259a..bc55b3db63 100644
--- a/modules/largefile-tests
+++ b/modules/largefile-tests
@@ -2,7 +2,6 @@ Files:
 tests/test-largefile.c
 
 Depends-on:
-assert-h
 intprops
 sys_types
 sys_stat
diff --git a/modules/year2038-tests b/modules/year2038-tests
index 63f00ee7f8..95fb6bdaf8 100644
--- a/modules/year2038-tests
+++ b/modules/year2038-tests
@@ -2,7 +2,6 @@ Files:
 tests/test-year2038.c
 
 Depends-on:
-assert-h
 intprops
 
 configure.ac:
diff --git a/tests/test-largefile.c b/tests/test-largefile.c
index ce5d8a0e2e..eb7861dae3 100644
--- a/tests/test-largefile.c
+++ b/tests/test-largefile.c
@@ -26,17 +26,26 @@
 #include <sys/stat.h>
 #include "intprops.h"
 
-/* Check the range of off_t.
-   With MSVC, this test succeeds only thanks to the 'sys_types' module.  */
-static_assert (TYPE_MAXIMUM (off_t) >> 31 >> 31 != 0);
-
-/* Check the size of the 'struct stat' field 'st_size'.
-   ,With MSVC, this test succeeds only thanks to the 'sys_stat' module.  */
-static struct stat st;
-static_assert (sizeof st.st_size == sizeof (off_t));
+/* Although these tests could be done with static_assert, the test
+   harness prefers dynamic checking.  */
 
 int
 main (void)
 {
-  return 0;
+  int result = 0;
+
+  /* Check the range of off_t.
+     With MSVC, this test succeeds only thanks to the 'sys_types' module.  */
+  if (TYPE_MAXIMUM (off_t) >> 31 >> 31 == 0)
+    result |= 1;
+
+  /* Check the size of the 'struct stat' field 'st_size'.
+     With MSVC, this test succeeds only thanks to the 'sys_stat' module.  */
+  {
+    struct stat st;
+    if (sizeof st.st_size != sizeof (off_t))
+      result |= 2;
+  }
+
+  return result;
 }
diff --git a/tests/test-year2038.c b/tests/test-year2038.c
index 0facf930ed..d1989eb432 100644
--- a/tests/test-year2038.c
+++ b/tests/test-year2038.c
@@ -28,11 +28,12 @@
 #include <sys/types.h>
 #include "intprops.h"
 
-/* Check the range of time_t.  */
-static_assert (TYPE_MAXIMUM (time_t) >> 31 != 0);
+/* Although this test could be done with static_assert, the test
+   harness prefers dynamic checking.  */
 
 int
 main (void)
 {
-  return 0;
+  /* Check the range of time_t.  */
+  return TYPE_MAXIMUM (time_t) >> 31 == 0;
 }
-- 
2.40.0

Reply via email to