Subject: | clang warning logical vs bitwise |
When compiling List-MoreUtils-XS 0.423 with clang I get this warning:
cc -c -I. -DNO_LOCALE_NUMERIC -DNO_LOCALE_COLLATE -fno-strict-aliasing -pipe -fstack-protector-strong -D_FORTIFY_SOURCE=2 -I/usr/local/include -O2 -DVERSION=\"0.423\" -DXS_VERSION=\"0.423\" -DPIC -fPIC "-I/usr/libdata/perl5/amd64-openbsd/CORE" XS.c
XS.xs:282:21: warning: logical not is only applied to the left hand side of this
bitwise operator [-Wlogical-not-parentheses]
if (!(PadnameFLAGS(name_sv)) & SVf_OK)
^ ~
XS.xs:282:21: note: add parentheses after the '!' to evaluate the bitwise
operator first
if (!(PadnameFLAGS(name_sv)) & SVf_OK)
^
( )
XS.xs:282:21: note: add parentheses around left hand side expression to silence
this warning
if (!(PadnameFLAGS(name_sv)) & SVf_OK)
^
( )
1 warning generated.
The code does not look correct. PadnameFLAGS is a bit field with
presumably some bits set. After logical not the value is 0 and the
condition is never true.
This is a copy of github issue
https://github.com/perl5-utils/List-MoreUtils-XS/issues/3