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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
      Known to fail|                            |10.2.0, 11.0, 7.3.0, 8.3.0,
                   |                            |9.2.0
                 CC|                            |msebor at gcc dot gnu.org
   Last reconfirmed|2016-11-17 00:00:00         |2021-3-31

--- Comment #4 from Martin Sebor <msebor at gcc dot gnu.org> ---
Reconfirmed with GCC 11.

GCC does issue -Wuninitialized without optimization on an equivalent test case
with an explicit ctor.  The difference between the two ctors is that B's has a
clobber:

$ cat pr78391.C && PRED_DUMP=euninit gcc -S -Wall pr78391.C
struct A { int x = w; int w = 10; };

int f ()
{
  A a;
  return a.x;
}

struct B { int x, w; B (): x(w), w (10) { } };

int g ()
{
  B b;
  return b.x;
}

void A::A (struct A * const this)
{
  int _1;

  <bb 2> :
  # VUSE <.MEM_2(D)>           <<< no clobber
  _1 = this_3(D)->w;           <<< -Wuninitialized
  # .MEM_4 = VDEF <.MEM_2(D)>
  this_3(D)->x = _1;
  # .MEM_5 = VDEF <.MEM_4>
  this_3(D)->w = 10;
  # VUSE <.MEM_5>
  return;

}


int f ()
{
  struct A a;
  int D.2439;
  int _3;

  <bb 2> :
  # .MEM_2 = VDEF <.MEM_1(D)>
  A::A (&a);
  # VUSE <.MEM_2>
  _3 = a.x;
  # .MEM_4 = VDEF <.MEM_2>
  a ={v} {CLOBBER};

  <bb 3> :
<L1>:
  # VUSE <.MEM_4>
  return _3;

}


void B::B (struct B * const this)
{
  int _1;

  <bb 2> :
  # .MEM_4 = VDEF <.MEM_2(D)>
  *this_3(D) ={v} {CLOBBER};   <<< clobber here
  # VUSE <.MEM_4>
  _1 = this_3(D)->w;           <<< -Wuninitialized
  # .MEM_5 = VDEF <.MEM_4>
  this_3(D)->x = _1;
  # .MEM_6 = VDEF <.MEM_5>
  this_3(D)->w = 10;
  # VUSE <.MEM_6>
  return;

}


pr78391.C: In constructor ‘B::B()’:
pr78391.C:9:30: warning: ‘*this.B::w’ is used uninitialized [-Wuninitialized]
    9 | struct B { int x, w; B (): x(w), w (10) { } };
      |                              ^
int g ()
{
  struct B b;
  int D.2442;
  int _3;

  <bb 2> :
  # .MEM_2 = VDEF <.MEM_1(D)>
  B::B (&b);
  # VUSE <.MEM_2>
  _3 = b.x;
  # .MEM_4 = VDEF <.MEM_2>
  b ={v} {CLOBBER};

  <bb 3> :
<L1>:
  # VUSE <.MEM_4>
  return _3;

}

Reply via email to