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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |diagnostic,
                   |                            |missed-optimization

--- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> ---
The FE emits

  <bb 2> :
  FRAME.16.FRAME_BASE.PARENT = 0B;
  a.data = 0B;
  _1 = a.data;
  if (_1 != 0B)
    goto <bb 3>; [INV]
  else
    goto <bb 9>; [INV]

  <bb 3> :
  _2 = a.dim[0].ubound;
  _3 = a.dim[0].lbound;
  _4 = _2 - _3;
  _20 = _4 + 1;
  _21 = _20;
  _22 = _21 + -1;
  S.8_23 = 0;

  <bb 4> :
  # S.8_12 = PHI <S.8_23(3), S.8_26(7)>
  if (S.8_12 > _22)
    goto <bb 8>; [INV]
  else
    goto <bb 5>; [INV]

where you see the loads from a.dim[0].{u,l}bound are uninitialized if
bb3 is entered.  With optimization turned on we only do the "maybe"
warning late which is after loads of optimization (everything inlined
into main()) that elided the loads.  Even w/o inlining test () is optimized
to just

test ()
{
  struct array01_foo a;

  <bb 2> [local count: 1073741824]:
  a.data = 0B;
  new (&a, &C.3979);
  a ={v} {CLOBBER};
  return;

maybe the FE can be a little bit smarter emitting

  <bb 2> :
  a.data = 0B;
  _1 = a.data;
  if (_1 != 0B)

?

Reply via email to