This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Use STATIC_ASSERT_STMT for checking compile-time invariants
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Fri, 15 Feb 2019 11:15:03 +0000 (11:15 +0000)
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>
Fri, 15 Feb 2019 11:23:35 +0000 (11:23 +0000)
Better to have the build fail if they're wrong than relying on the
code path being hit at runtime in a DEBUGGING build.

regcomp.c

index 41d2582..088b1df 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -18989,9 +18989,8 @@ Perl__get_regclass_nonbitmap_data(pTHX_ const regexp *prog,
                         invlist = prop_definition;
                     }
 
-                    assert(ONLY_LOCALE_MATCHES_INDEX == 1 + INVLIST_INDEX);
-                    assert(DEFERRED_USER_DEFINED_INDEX == 1
-                                                + ONLY_LOCALE_MATCHES_INDEX);
+                    STATIC_ASSERT_STMT(ONLY_LOCALE_MATCHES_INDEX == 1 + INVLIST_INDEX);
+                    STATIC_ASSERT_STMT(DEFERRED_USER_DEFINED_INDEX == 1 + ONLY_LOCALE_MATCHES_INDEX);
 
                     av_store(av, INVLIST_INDEX, invlist);
                     av_fill(av, (ary[ONLY_LOCALE_MATCHES_INDEX])