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

Martin Sebor <msebor at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |msebor at gcc dot gnu.org
      Known to fail|4.9.3, 5.2.0                |10.2.0, 11.0, 4.9.4, 5.5.0,
                   |                            |6.4.0, 7.2.0, 8.3.0, 9.1.0

--- Comment #3 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirmed with GCC 11.  It's not a regression.  With a patch I'm working with
GCC issues the following warning and notes confirming the analysis from comment
#1 and #2.

pr68548.c: In function ‘foo’:
pr68548.c:14:17: warning: ‘data0’ may be used uninitialized in this function
[-Wmaybe-uninitialized]
   14 |                 bar(data0);
      |                 ^~~~~~~~~~
pr68548.c:7:18: note: when ‘(writemask & 1) == 0’
    7 |         unsigned data0;
      |                  ^~~~~
pr68548.c:7:18: note: used when ‘(writemask & 1) == 0’
pr68548.c:7:18: note: ‘data0’ was declared here

EVRP knows to fold the test for data0 != data to false but nothing substitutes
data for data0 when the value is passed to another function or returned.  So
the following, for instance, doesn't trigger a warning because the data0 - data
subtraction is folded into zero.

int x;

void baz (unsigned writemask, unsigned data) {
    unsigned remaining = X;
    unsigned data0;

    if (writemask & X) data0 = data;

    remaining &= ~writemask;
    if (remaining == 0)
      x = data0 - data;
}

Reply via email to