sapi/phpdbg/phpdbg.c:861: 2 * wrong operator ?
Description
I just compiled php-8.1.4 with the new compiler clang-14. It said:
php-8.1.4/sapi/phpdbg/phpdbg.c:861:7: warning: use of bitwise '|' with boolean operands [-Wbitwise-instead-of-logical] php-8.1.4/sapi/phpdbg/phpdbg.c:861:8: warning: use of bitwise '&' with boolean operands [-Wbitwise-instead-of-logical]
Source code is
if (((fstat(fileno(stderr), &stat[2]) < 0) & (fstat(fileno(stdout), &stat[0]) < 0)) | (fstat(data->fd, &stat[1]) < 0)) {
Maybe better code:
if (((fstat(fileno(stderr), &stat[2]) < 0) && (fstat(fileno(stdout), &stat[0]) < 0)) || (fstat(data->fd, &stat[1]) < 0)) {
PHP Version
pgp 8.1.4
Operating System
Linux fedora 36 beta
It seems to me the use of the bitwise operators is by design; using logical operators instead could lead to short-circuit behavior, so that stat may not be properly initialized. Still, I'd change that code to do the statting upfront, and the use logical operators in the if-clause.
cc @bwoebi
Yeah, I agree. But yes, it's to ensure all fstat()s happen.
Reclassifying as feature request, since there is no actual bug.