|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-01-12 09:02 UTC] nikic@php.net
[2021-01-12 16:22 UTC] nathanael at prolegis dot ca
[2021-01-14 09:09 UTC] nikic@php.net
[2021-01-14 09:09 UTC] nikic@php.net
-Status: Open
+Status: Closed
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Description: ------------ When compiling a php extension with GCC we're getting a warning with gcc which is a fatal error with clang. When compiling we get the following warning/output: /usr/include/php/Zend/zend_types.h:264:50: warning: narrowing conversion of '((((12 == 17) ? ((1 << 2) | (1 << 3)) : ((12 == 16) ? (((((((((1 << 1) | (1 << 2)) | (1 << 3)) | (1 << 4)) | (1 << 5)) | (1 << 6)) | (1 << 7)) | (1 << 8)) | (1 << 9)) : (1 << 12))) | ((& arg)->Php::Argument::allowNull() ? 2 : 0)) | 0)' from 'int' to 'uint32_t {aka unsigned int}' inside { } [-Wnarrowing] | ((allow_null) ? _ZEND_TYPE_NULLABLE_BIT : 0) | (extra_flags)) ^ /usr/include/php/Zend/zend_types.h:260:11: note: in definition of macro 'ZEND_TYPE_INIT_MASK' { NULL, (_type_mask) } ^~~~~~~~~~ zend/callable.h:217:62: note: in expansion of macro 'ZEND_TYPE_INIT_CODE' case Type::Callable: info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_CALLABLE, arg.allowNull(), 0); break; // anything that can be invoke the issue is arg.allowNull() it returns an int, even though its 0 or 1 there's an the warning is there. If I just pass a 0, there is no warning. Another user commented as follows: https://github.com/CopernicaMarketingSoftware/PHP-CPP/pull/471#discussion_r553716780 Basically saying the issue was "The problem is because the zend_type struct takes a uint32_t, but they defined _ZEND_TYPE_NULLABLE_BIT as 0x2, and in C/C++ constants are signed by default. " Is this correct? If so can the _ZEND_TYPE_NULLABLE_BIT be defined as 0x2u instead? I've also tried casting the result of arg.allowNull to uint32_t to no avail. Test script: --------------- info->type = (zend_type) ZEND_TYPE_INIT_CODE(IS_UNDEF, arg.allowNull(), 0); Expected result: ---------------- No warnings about type narrowing when passing an int.