[Bug analyzer/104680] identical inner condition not detected

dmalcolm at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Thu Mar 3 14:19:33 GMT 2022


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104680

--- Comment #4 from David Malcolm <dmalcolm at gcc dot gnu.org> ---
> trunk.git/gcc/d/expr.cc:689:17: warning: Identical inner 'if' condition is always true. [identicalInnerCondition]

In 'void visit (CatExp *e)':
 682   │     if (e->e1->op == EXP::concatenate)
 683   │       {
 684   │     /* Flatten multiple concatenations to an array.
 685   │        So the expression ((a ~ b) ~ c) becomes [a, b, c]  */
 686   │     int ndims = 2;
 687   │ 
 688   │     for (Expression *ex = e->e1; ex->op == EXP::concatenate;)
 689   │       {
 690   │         if (ex->op == EXP::concatenate)
 691   │           {
 692   │         ex = ex->isCatExp ()->e1;
 693   │         ndims++;
 694   │           }
 695   │       }

Looks like the ex->op == EXP::concatenate in line 690 is indeed checked by the
loop guard at line 688, so this code does look suspicious to me.


More information about the Gcc-bugs mailing list