Branch: refs/heads/yves/alternate_pr_for_21296 Home: https://github.com/Perl/perl5 Commit: 65a3b460d5372231b3324bf30f67d298cba36c95 https://github.com/Perl/perl5/commit/65a3b460d5372231b3324bf30f67d298cba36c95 Author: Yves Orton <demer...@gmail.com> Date: 2023-07-27 (Thu, 27 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.