[Bug tree-optimization/105109] New: [12 Regression] False positive warning on complex float code since r12-155

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Wed Mar 30 15:53:31 GMT 2022


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

            Bug ID: 105109
           Summary: [12 Regression] False positive warning on complex
                    float code since r12-155
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jakub at gcc dot gnu.org
  Target Milestone: ---

Since r12-155-gd8e1f1d24179690fd9c0f63c27b12e030010d9ea with -O -Wall on
static void foo(int dim,float _Complex f0[])
{
  int d;
  f0[0] -= 3.14;
  for (d = 0; d < dim; ++d) f0[0] += 3.14;
}
void bar(int dim, const float _Complex u_t[], float _Complex f0[])
{
  float _Complex exp[1] = {0.};
  foo(dim, exp);
  f0[0] = u_t[0] - exp[0];
}
we emit
In function ‘foo’,
    inlined from ‘bar’ at rh2066856.c:10:3:
rh2066856.c:4:9: warning: ‘exp[0]’ is used uninitialized [-Wuninitialized]
    4 |   f0[0] -= 3.14;
      |   ~~~~~~^~~~~~~
rh2066856.c: In function ‘bar’:
rh2066856.c:9:18: note: ‘exp[0]’ was declared here
    9 |   float _Complex exp[1] = {0.};
      |                  ^~~

Before dce3 we have:
  IMAGPART_EXPR <exp$0> = 0.0;
  REALPART_EXPR <exp$0> = -3.1400001049041748046875e+0;
and then only read or modify REALPART_EXPR <exp$0> before final
  exp$0 ={v} {CLOBBER};
dce3 seems to decide that because nothing reads IMAGPART_EXPR <exp$0>, the
store of it is useless too.
And later on, ccp3 puts exp$0 into SSA form and changes it into:
  _5 = IMAGPART_EXPR <exp$0_12(D)>;
  exp$0_26 = COMPLEX_EXPR <-3.1400001049041748046875e+0, _5>;
and
  _1 = IMAGPART_EXPR <exp$0_2>;
  exp$0_11 = COMPLEX_EXPR <_19, _1>;
etc.
And the uninit1 pass later complains because the second argument of
COMPLEX_EXPR is IMAGPART_EXPR of uninitialized SSA_NAME.

So, should DCE avoid doing that?  Or better when turning it into SSA form find
out that only one half of it is ever used and just rewrite that half into a
SSA_NAME?


More information about the Gcc-bugs mailing list