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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|g++ does not raise "xxx is  |g++ does not raise "xxx may
                   |used uninitialized" warning |be used uninitialized"
                   |under some conditions       |warning on dead code when
                   |                            |optimizing
   Last reconfirmed|                            |2022-08-19
          Component|c++                         |tree-optimization
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |ASSIGNED

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The issue is that for f3() we'd emit a may-uninitialized warning because f1()
could have thrown and thus v3{v3} is only executed conditionally.  For f2()
v2{v2} is always executed (when f2 is entered).  The late diagnostic pass
that would emit may-uninitialized warnings doesn't get to see the v3{v3}
initialization because it was removed as dead code.

When not optimizing we choose to diagnose may-uninit before eliminating v3{v3}.

Confirmed.  Not sure if we want to fix this.  We eventually might use a
different predicate than post-domination for whether a stmt is considered
always executed (ignoring EH and abnormal control flow).  Greedily
following "fallthru" edges might work for this, also implementing the
unreachable edge honoring the ??? comment says.

I have a patch.

Reply via email to