Branch: refs/heads/yves/alternate_pr_for_21296 Home: https://github.com/Perl/perl5 Commit: 4f70673f48fcf64f03f86ce42bf46c1dd0b2b5f3 https://github.com/Perl/perl5/commit/4f70673f48fcf64f03f86ce42bf46c1dd0b2b5f3 Author: Yves Orton <demer...@gmail.com> Date: 2023-07-26 (Wed, 26 Jul 2023)
Changed paths: M perl.h M regexec.c Log Message: ----------- regexec.c - if we know that PL_sawampersand is a constant we can ifdef away some code 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 ever execute. Some versions of Clang notice that these expressions are always true (either in these expressions or ones that follow that do the same thing) and then complain about constants being used in an logical expression. So when PERL_SAWAMPERSAND is not defined we define SAWAMPERSAND_ALWAYS so we can detect this and simply not compile these blocks at all. This should silence the warning from Clang about this logic. IMO Clang probably shouldn't warn about things like this, as then the code would be compiled for correctness but then compiled away because of the constant. This patch means the code won't be compiled at all.