Branch: refs/heads/blead Home: https://github.com/Perl/perl5 Commit: 2a8fc21e747997d36fac7dceac7fa67680868e09 https://github.com/Perl/perl5/commit/2a8fc21e747997d36fac7dceac7fa67680868e09 Author: Yves Orton <demer...@gmail.com> Date: 2023-07-31 (Mon, 31 Jul 2023)
Changed paths: M regexec.c Log Message: ----------- regexec.c - restructure code that boils down to a constant conditional See also https://github.com/Perl/perl5/pull/21296. When PERL_SAWAMPERSAND is not defined then Pl_sawampersand is defined to be (SAWAMPERSAND_LEFT|SAWAMPERSAND_MIDDLE|SAWAMPERSAND_RIGHT). Which means that the clause in the first if block: && !(PL_sawampersand & SAWAMPERSAND_RIGHT) and the clause in the second if block: && !(PL_sawampersand & SAWAMPERSAND_LEFT) will never be true. Thus neither of these blocks will execute in a normal build where PERL_SAWAMPERSAND is not defined. Nevertheless some versions of Clang notice that a related expression guarded by these clauses is also constant, and mixes '&' and '&&' together and then warns about it: $ clang-17 ... regexec.c regexec.c:3589:21: warning: use of logical '&&' with constant operand [-Wconstant-logical-operand] 3588 | if ((PL_sawampersand & SAWAMPERSAND_RIGHT) | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3589 | && min > RXp_OFFS_END(prog,0) | ^ regexec.c:3589:21: note: use '&' for a bitwise operation 3589 | && min > RXp_OFFS_END(prog,0) | ^~ | & regexec.c:3589:21: note: remove constant to silence this warning Restructuring the clauses into a nested if should fix this. Along the way we fix a related I32/SSize_t mismatch, and eliminate an unnecessary duplicate use of RXp_OFFS_END(prog,0) call, which these days is a more complex and expensive macro than it once was. Thanks to the github user @Logikable for calling this to our attention with a different patch.