summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-04-15 12:02:04 -0600
committerKarl Williamson <khw@cpan.org>2021-08-25 11:16:34 -0600
commitde40ad3f34506856fa677ea5a7e2decb71cf29a7 (patch)
treec661fe8fda215b38d60538f2c94e34f9bd6e1e7a /handy.h
parent296969d3c2b710adc063a323e364dae12729e066 (diff)
downloadperl-de40ad3f34506856fa677ea5a7e2decb71cf29a7.tar.gz
handy.h: Skip non-ptr assertion on old gcc's
See https://github.com/Perl/perl5/issues/18655, which this fixes.
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/handy.h b/handy.h
index a6266f0448..52e1c6e3d8 100644
--- a/handy.h
+++ b/handy.h
@@ -1424,9 +1424,16 @@ or casts
# define WIDEST_UTYPE U32
#endif
-/* Use this, where there could be some confusion, as a static assert in macros
- * to make sure that a parameter isn't a pointer. */
-#define ASSERT_NOT_PTR(x) ((x) | 0)
+/* Where there could be some confusion, use this as a static assert in macros
+ * to make sure that a parameter isn't a pointer. But some compilers can't
+ * handle this. The only one known so far that doesn't is gcc 3.3.6; the check
+ * below isn't thorough for such an old compiler, so may have to be revised if
+ * experience so dictates. */
+#if ! PERL_IS_GCC || PERL_GCC_VERSION_GT(3,3,6)
+# define ASSERT_NOT_PTR(x) ((x) | 0)
+#else
+# define ASSERT_NOT_PTR(x) (x)
+#endif
/* FITS_IN_8_BITS(c) returns true if c doesn't have a bit set other than in
* the lower 8. It is designed to be hopefully bomb-proof, making sure that no
@@ -1443,7 +1450,7 @@ or casts
/* The '| 0' part ensures a compiler error if c is not integer (like e.g., a
* pointer) */
# define FITS_IN_8_BITS(c) ( (sizeof(c) == 1) \
- || ((WIDEST_UTYPE)((c) | 0) == ((U8)(c))))
+ || ((WIDEST_UTYPE) ASSERT_NOT_PTR(c)) == ((U8)(c)))
#else
# define FITS_IN_8_BITS(c) (1)
#endif