|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-03-01 19:44 UTC] lstefani at fortresstech dot com
Description:
------------
Zend/zend_operators.h: In function `void* zend_memrchr(const void*, int, unsigned int)':
Zend/zend_operators.h:250: warning: cast from `const void*' to `unsigned char*' discards qualifiers from pointer target type
Zend/zend_operators.h:250: warning: cast from `const void*' to `unsigned char*' discards qualifiers from pointer target type
In code snippet, line 250 refers to the two recasts of argument s.
Reproduce code:
---------------
static inline void *zend_memrchr(const void *s, int c, size_t n)
{
register unsigned char *e;
if (n <= 0) {
return NULL;
}
for (e = (unsigned char *)s + n - 1; e >= (unsigned char *)s; e--) {
if (*e == (unsigned char)c) {
return (void *)e;
}
}
return NULL;
}
Expected result:
----------------
No compiler warnings.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 18:00:01 2025 UTC |
Would like someone to reopen this bug if possible, it is preventing me from using -Werror compiler flag. Have seen this warning while compiling for both PHP 5 and PHP 7 without fail. Here is part of the build log when cross-compiling to arm64 in a Debian 11 Docker container. libtool: compile: aarch64-linux-gnu-g++ -DHAVE_CONFIG_H -I. -I./include -Wall -Wextra -Wshadow -pedantic -fPIC -fno-rtti -std=c++14 -flto -ffunction-sections -fdata-sections -g -I/usr/include/php/20190902 -I/usr/include/php/20190902/main -I/usr/include/php/20190902/TSRM -I/usr/include/php/20190902/Zend -I/usr/include/php/20190902/ext -I/usr/include/php/20190902/ext/date/lib -Wno-unused -Wno-unused-parameter -c plugin.cpp -fPIC -DPIC -o src/.libs/plugin.o In file included from /usr/include/php/20190902/Zend/zend.h:356, from /usr/include/php/20190902/main/php.h:34, from src/ombu_xlic.cpp:2: /usr/include/php/20190902/Zend/zend_operators.h: In function 'const void* zend_memrchr(const void*, int, size_t)': /usr/include/php/20190902/Zend/zend_operators.h:197:13: warning: type qualifiers ignored on cast result type [-Wignored-qualifiers] 197 | if (*e == (const unsigned char)c) { | ^~~~~~~~~~~~~~~~~~~~~~