From 3082268e506fb61e566c244b1dfb00bf5e5effdc Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Fri, 11 Oct 2024 11:57:01 +0200 Subject: [PATCH] Push NDEBUG handling down to zend_portability.h As is, `NEDBUG` is set to match `PHP_DEBUG` (which matches `ZEND_DEBUG`) in php.h right before including assert.h; however, assert.h is already included at this point, so the `NDEBUG` handling is useless. We push it down to zend_portability.h, where it has effect. The alternative would be to drop that code in php.h altogether, but that would make some test assumptions invalid. E.g. a build with `CFLAGS=-DNDEBUG ./configure --enable-debug-assertions` would fail internal_functions001.phpt, because the userland `PHP_DEBUG` is true, but assertions would not be evaluated. --- Zend/zend_portability.h | 5 +++++ main/php.h | 7 ------- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h index f4609428326c7..5acbebf30ff96 100644 --- a/Zend/zend_portability.h +++ b/Zend/zend_portability.h @@ -47,6 +47,11 @@ #include "../TSRM/TSRM.h" #include +#if ZEND_DEBUG +# undef NDEBUG +#elif !defined(NDEBUG) +# define NDEBUG +#endif #include #include diff --git a/main/php.h b/main/php.h index c00777a1b40a0..a7ff4b6e35bea 100644 --- a/main/php.h +++ b/main/php.h @@ -109,13 +109,6 @@ typedef int pid_t; # endif #endif -#if PHP_DEBUG -#undef NDEBUG -#else -#ifndef NDEBUG -#define NDEBUG -#endif -#endif #include #ifdef HAVE_UNIX_H