]> Savannah Git Hosting - gnulib.git/commitdiff
stdnoreturn: deprecate
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Dec 2022 09:29:29 +0000 (01:29 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 24 Dec 2022 09:34:31 +0000 (01:34 -0800)
C23 says <stdnoreturn.h> is obsolescent, so deprecate the
stdnoreturn module.  I don't think it was being used anyway
as it had too many problems.
* modules/stdnoreturn: Mark as obsolete.

ChangeLog
NEWS
doc/noreturn.texi
doc/posix-headers/stdnoreturn.texi
lib/stdnoreturn.in.h
modules/stdnoreturn

index 3b6c6cf98e3d2eca8bde6a4ae8c2b35899891c57..91370af9648fa31c17c56f1a100fcfc4b2fcfc7d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2022-12-24  Paul Eggert  <eggert@cs.ucla.edu>
+
+       stdnoreturn: deprecate
+       C23 says <stdnoreturn.h> is obsolescent, so deprecate the
+       stdnoreturn module.  I don't think it was being used anyway
+       as it had too many problems.
+       * modules/stdnoreturn: Mark as obsolete.
+
 2022-12-23  Paul Eggert  <eggert@cs.ucla.edu>
 
        file-has-acl: improve recent NFSv4 support
diff --git a/NEWS b/NEWS
index bc620ce86a75a2c9454e64b2655f6d0da4be4a8c..dd2374c4fd54d31ad65bee3abba3b1a9b400738c 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -74,6 +74,9 @@ User visible incompatible changes
 
 Date        Modules         Changes
 
+2022-12-24  stdnoreturn     This module is deprecated.  Use _Noreturn
+                            or the noreturn module instead.
+
 2022-12-21  ctime           This module is deprecated.  Use localtime_r
                             and strftime (or even sprintf) instead.
 
index a3a394409ce871a7133e68149f9df0ed6fa02a42..ad0a286f4a44a4a95a5865f1e94cd5f9c6ceccd3 100644 (file)
 @cindex @code{noreturn}
 @cindex @code{stdnoreturn}
 A "non-returning" function is a function which cannot return normally.
-It can transfer control only through @code{longjmp()}, @code{throw}
-(in C++), or similar mechanisms.  The most prominent function of this
-class is the @code{abort} function.  Non-returning functions are
+Instead of returning, it can loop forever, or it can transfer control via
+@code{abort}, @code{execvp}, @code{exit}, @code{longjmp}, @code{throw}
+(in C++), or similar mechanisms.  Non-returning functions are
 declared with a @code{void} return type.
 
 It helps the compiler's ability to emit sensible warnings, following
 data-flow analysis, to declare which functions are non-returning.
+It can also help generate more-efficient code, as there is no need
+to save a return address when calling a non-returning function.
 
-To decorate function declarations and function definitions, you can
-use the @code{_Noreturn} keyword.  No modules are needed, as Gnulib
+Gnulib has multiple ways to support such a declaration''
+
+@itemize @bullet
+@item
+The @code{_Noreturn} keyword.  No modules are needed, as Gnulib
 arranges for @code{<config.h>} to define @code{_Noreturn} to an
 appropriate replacement on platforms lacking it.
+Unfortunately, although this approach works for all current C versions,
+the @code{_Noreturn} keyword is obsolescent in C23.
 
-Gnulib has two modules that support such a declaration:
-
-@itemize @bullet
 @item
 The @samp{noreturn} module.  It provides a way to put this declaration
 at function declarations, at function definitions, and in function
@@ -44,20 +48,13 @@ definitions.
 @end itemize
 @noindent
 The include file is @code{<noreturn.h>}.
-
-@item
-The @samp{stdnoreturn} module.  This can improve readability by
-letting you use @code{noreturn} instead of @code{_Noreturn};
-unfortunately, @code{noreturn} is a no-op on some platforms even
-though @code{_Noreturn} works on them.  The include file is
-@code{<stdnoreturn.h>}.
 @end itemize
 
-Which of the two modules to use?  If the non-returning functions you
+Which of the approaches to use?  If the non-returning functions you
 have to declare are unlikely to be accessed through function pointers,
-you should use module @code{stdnoreturn}; otherwise the module
+you should use @code{_Noreturn}; otherwise the module
 @code{noreturn} provides for better data-flow analysis and thus for
 better warnings.
 
-For a detailed description of the @code{stdnoreturn} module, see
-@ref{stdnoreturn.h}.
+There is also an obsolete @code{stdnoreturn} module, but its use is no
+longer recommended.
index 3e1c5882db03dccfc406bee65fb4c27d43c74547..ebe31ffc9f03434ba85d17d219372d66750f89b4 100644 (file)
@@ -22,6 +22,8 @@ MSVC/clang.
 Portability problems not fixed by Gnulib:
 @itemize
 @item
+@code{<stdnoreturn.h>} and the @code{noreturn} macro are obsolescent in C23.
+@item
 @code{<stdnoreturn.h>} cannot be #included in C++ mode on some platforms:
 FreeBSD 13.1.
 @item
index d9e746699deb3271c887a85bd6d3d1da99badcad..446e11b0b2d63b063bd6adaee0f18d666a3afb9d 100644 (file)
@@ -24,7 +24,9 @@
    References:
    ISO C11 (latest free draft
    <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf>)
-   section 7.23 */
+   section 7.23
+
+   <stdnoreturn.h> is obsolescent in C23, so new code should avoid it.  */
 
 /* The definition of _Noreturn is copied here.  */
 
index 1ef894d51fa5b38918505e1ad4a46111c8f5563a..ce6b04a35e2b3ec3ddfe5db08aad9771cdae1316 100644 (file)
@@ -1,6 +1,12 @@
 Description:
 A <stdnoreturn.h> that nearly conforms to ISO C11.
 
+Status:
+obsolete
+
+Notice:
+This module is obsolete.
+
 Files:
 lib/stdnoreturn.in.h
 m4/stdnoreturn.m4