On Tue, Apr 01, 2025 at 10:09:56AM +0200, Martin Jambor wrote:
> The simple fix is to initialize the variable to nullptr in the source,
> of course. :-)

It is a false positive.
  gimple *stmt;
...
  for (gsi = gsi_last_bb (bb); !gsi_end_p (gsi); gsi_prev (&gsi))
    {
      stmt = gsi_stmt (gsi);
...
    }
...
  if (gsi_end_p (gsi))
    {
...
      return;
    }
...
  if ((stmt_could_throw_p (cfun, stmt)
       && !stmt_can_throw_external (cfun, stmt)) || EDGE_COUNT (bb->succs) > 1)
So, it is possible that stmt isn't initialized if there are no statements in
that bb at all, but in that case it recurses on the predecessors and
returns, so when stmt is used later in the function, it must be initialized.
If gsi_end_p is not for some reason inlined nor IPA analyzed then the
compiler might not know that if gsi doesn't change then two gsi_end_p
calls will always give the same answer.
I agree
-  gimple *stmt;
+  gimple *stmt = NULL;
doesn't hurt though.
And I think this potential uninit false positive is there for quite a while,
I think since r10-44-gd407e7f53b4a9c3f6.

        Jakub

Reply via email to