summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2020-07-06 16:24:33 +0100
committerDagfinn Ilmari Mannsåker <ilmari@ilmari.org>2020-07-20 13:58:53 +0100
commitc1d551e18b0505f4fadf5d7cd6b07de35589bd42 (patch)
treed20843f84286df374ee0a6d0e0b0b905b3b6acc9
parent233050fdd35e6b614a1a299227c441350fbcc1e3 (diff)
downloadperl-c1d551e18b0505f4fadf5d7cd6b07de35589bd42.tar.gz
Use static asserts when comparing sizeof() to a constant
-rw-r--r--regcomp.c2
-rw-r--r--sv.c2
-rw-r--r--sv.h4
3 files changed, 4 insertions, 4 deletions
diff --git a/regcomp.c b/regcomp.c
index 53e24bbda0..781399efa2 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -7416,7 +7416,7 @@ S_set_regex_pv(pTHX_ RExC_state_t *pRExC_state, REGEXP *Rx)
PERL_ARGS_ASSERT_SET_REGEX_PV;
/* make sure PL_bitcount bounds not exceeded */
- assert(sizeof(STD_PAT_MODS) <= 8);
+ STATIC_ASSERT_STMT(sizeof(STD_PAT_MODS) <= 8);
p = sv_grow(MUTABLE_SV(Rx), wraplen + 1); /* +1 for the ending NUL */
SvPOK_on(Rx);
diff --git a/sv.c b/sv.c
index 9c7f3ba45e..494b77ca66 100644
--- a/sv.c
+++ b/sv.c
@@ -12824,7 +12824,7 @@ Perl_sv_vcatpvfn_flags(pTHX_ SV *const sv, const char *const pat, const STRLEN p
(!UVCHR_IS_INVARIANT(uv) && SvUTF8(sv)))
&& !IN_BYTES)
{
- assert(sizeof(ebuf) >= UTF8_MAXBYTES + 1);
+ STATIC_ASSERT_STMT(sizeof(ebuf) >= UTF8_MAXBYTES + 1);
eptr = ebuf;
elen = uvchr_to_utf8((U8*)eptr, uv) - (U8*)ebuf;
is_utf8 = TRUE;
diff --git a/sv.h b/sv.h
index 2f4a85faba..6027f947e1 100644
--- a/sv.h
+++ b/sv.h
@@ -2302,7 +2302,7 @@ Evaluates C<sv> more than once. Sets C<len> to 0 if C<SvOOK(sv)> is false.
10:28 <+meta> Nicholas: crash
*/
# define SvOOK_offset(sv, offset) STMT_START { \
- assert(sizeof(offset) == sizeof(STRLEN)); \
+ STATIC_ASSERT_STMT(sizeof(offset) == sizeof(STRLEN)); \
if (SvOOK(sv)) { \
const U8 *_crash = (U8*)SvPVX_const(sv); \
(offset) = *--_crash; \
@@ -2326,7 +2326,7 @@ Evaluates C<sv> more than once. Sets C<len> to 0 if C<SvOOK(sv)> is false.
#else
/* This is the same code, but avoids using any temporary variables: */
# define SvOOK_offset(sv, offset) STMT_START { \
- assert(sizeof(offset) == sizeof(STRLEN)); \
+ STATIC_ASSERT_STMT(sizeof(offset) == sizeof(STRLEN)); \
if (SvOOK(sv)) { \
(offset) = ((U8*)SvPVX_const(sv))[-1]; \
if (!(offset)) { \