[php-src] Issue #12999: PHP 8.3: memchr needs explicit cast if strnlen not available

From: Date: Fri, 22 Dec 2023 12:46:42 +0000
Subject: [php-src] Issue #12999: PHP 8.3: memchr needs explicit cast if strnlen not available
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-246104@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/12999 Author: rainerjung ### Description This is a build problem: ``` .../Zend/zend_operators.h: In function 'size_t zend_strnlen(const char*, size_t)': .../Zend/zend_operators.h:272:24: error: invalid conversion from 'const void*' to 'const char*' [-fpermissive] 272 | const char *p = memchr(s, '\0', maxlen); | ~~~~~~^~~~~~~~~~~~~~~~~ | | | const void* ``` This code is only compiled if HAVE_STRNLEN is not defined. So it is not compiled e.g. on Linux, but on Solaris 10. A simple patch to fix this is: ``` --- Zend/zend_operators.h 2023-12-20 13:44:38.000000000 +0100 +++ Zend/zend_operators.h 2023-12-22 13:23:35.110296202 +0100 @@ -269,7 +269,7 @@ #if defined(HAVE_STRNLEN) return strnlen(s, maxlen); #else - const char *p = memchr(s, '\0', maxlen); + const char *p = (const char *)memchr(s, '\0', maxlen); return p ? p-s : maxlen; #endif } ``` Note, that this pattern is already used in the same file in several places that use memchr. Just not in this one line which gets only conditionally compiled. Please don't force me to make a pull request for this trivial change. Thanks! ### PHP Version PHP 8.3.1 ### Operating System Solaris 10

« previous php.bugs (#246104) next »