* lib/glthread/thread.c (gl_thread_create):
Define as a function only if multithreading.
This is cleaner than my previous patch today that sometimes made
it _Noreturn, as the function’s definition and declaration now always
agree on noreturnedness, and it pushes the noreturnedness issue up
to the caller.  Also, it suppresses GCC’s “warning: function
declared 'noreturn' has a 'return' statement”.
---
 ChangeLog             | 9 +++++++++
 lib/glthread/thread.c | 7 +++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 336120bfe6..eac1bbe281 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2026-04-25  Paul Eggert  <[email protected]>
 
+       thread: better nonreturn fix for gl_thread_create
+       * lib/glthread/thread.c (gl_thread_create):
+       Define as a function only if multithreading.
+       This is cleaner than my previous patch today that sometimes made
+       it _Noreturn, as the function’s definition and declaration now always
+       agree on noreturnedness, and it pushes the noreturnedness issue up
+       to the caller.  Also, it suppresses GCC’s “warning: function
+       declared 'noreturn' has a 'return' statement”.
+
        thread: pacify gcc -Wunused-value
        * lib/glthread/thread.h (glthread_atfork, glthread_sigmask)
        (glthread_create, glthread_join): Evaluate arguments even when
diff --git a/lib/glthread/thread.c b/lib/glthread/thread.c
index f08a28c0da..261806c74b 100644
--- a/lib/glthread/thread.c
+++ b/lib/glthread/thread.c
@@ -204,10 +204,8 @@ const gl_thread_t gl_null_thread /* = { .p = NULL } */;
 
 /* ========================================================================= */
 
-#if !(USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS \
-      || USE_WINDOWS_THREADS)
-_Noreturn
-#endif
+#if (USE_ISOC_THREADS || USE_POSIX_THREADS || USE_ISOC_AND_POSIX_THREADS \
+     || USE_WINDOWS_THREADS)
 gl_thread_t
 gl_thread_create (void *(*func) (void *arg), void *arg)
 {
@@ -217,3 +215,4 @@ gl_thread_create (void *(*func) (void *arg), void *arg)
     abort ();
   return thread;
 }
+#endif
-- 
2.53.0


Reply via email to