]> Savannah Git Hosting - gnulib.git/commitdiff
verify: port ‘assume’ to C23 non-GCC
authorPaul Eggert <eggert@cs.ucla.edu>
Wed, 10 Aug 2022 06:20:48 +0000 (23:20 -0700)
committerBruno Haible <bruno@clisp.org>
Wed, 31 Aug 2022 23:24:38 +0000 (01:24 +0200)
* lib/verify.h (assume): Use C23's unreachable if available
and if GCC and/or MSC primitives are not available.

ChangeLog
lib/verify.h

index 3c4de6120e37c2d8bef2dfc802138c4604a8f173..d3fa2e0ddcc779290841fbfdedbba5bc6a56a147 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2022-08-09  Paul Eggert  <eggert@cs.ucla.edu>
+
+       verify: port ‘assume’ to C23 non-GCC
+       * lib/verify.h (assume): Use C23's unreachable if available
+       and if GCC and/or MSC primitives are not available.
+
 2022-07-31  Bruno Haible  <bruno@clisp.org>
 
        gendocs.sh: Fix error when invoking 'perl' (regression 2022-07-23).
index c2d2a5667065fbd961170e041aad7d5efbfb4167..86bfe8d3092ddc3857a070e256b19a86dd457db4 100644 (file)
@@ -300,13 +300,16 @@ template <int w>
 # define assume(R) ((R) ? (void) 0 : __builtin_unreachable ())
 #elif 1200 <= _MSC_VER
 # define assume(R) __assume (R)
+#elif 202311L <= __STDC_VERSION__
+# include <stddef.h>
+# define assume(R) ((R) ? (void) 0 : unreachable ())
 #elif (defined GCC_LINT || defined lint) && _GL_HAS_BUILTIN_TRAP
   /* Doing it this way helps various packages when configured with
      --enable-gcc-warnings, which compiles with -Dlint.  It's nicer
-     when 'assume' silences warnings even with older GCCs.  */
+     if 'assume' silences warnings with GCC 3.4 through GCC 4.4.7 (2012).  */
 # define assume(R) ((R) ? (void) 0 : __builtin_trap ())
 #else
-  /* Some tools grok NOTREACHED, e.g., Oracle Studio 12.6.  */
+  /* Some older tools grok NOTREACHED, e.g., Oracle Studio 12.6 (2017).  */
 # define assume(R) ((R) ? (void) 0 : /*NOTREACHED*/ (void) 0)
 #endif