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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|NEW                         |RESOLVED

--- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> ---
This isn't wrong-debug but optimization:

unsigned char o() {
  int l_1339[3];
  int *ab = &l_1339[2];
  int k;
  m = 0;
  for (; m < 3; m++)
    l_1339[m] = 8;
  p(l_1339);
  for (; j <= 7; j++) {
    for (;; f--)
      if (*a)
        break;
    char *ac;
    char *ad[30];
    char *ae = ad;
    char *f = &ae;
    k = 0;
    for (; k < 3; k++)
      ad[k] = &ac;
    *ab = 0 != &g;
  }; //     optimize_me_not()
}

the l_1339 contents are preserved for the call to p which can observe
l_1339.  The later store of l_1339[2] = 1 is elided because the program
doesn't observe it.  We do not preserve such stores in debug stmts as
there is no debug stmt kind for memory (l_1339 is address taken).

We do not guarantee that program state after each sequence point is
correctly reflected in debug info but only where the side-effects produced
are actually observable by the running program as opposed to a debugger.
When not optimizing we attempt to guarantee the former wherever possible.

Implementation-wise it's the

  l_1339 ={v} {CLOBBER(eos)};
  return;

clobber at the end of the function that allows to remove the dead store.

Note there has been attempts by Richard S. to add debug info for removed
dead stores but it never got accepted.

Likewise "dead" control flow isn't preserved with optimization so you
cannot alter it to become non-dead by altering variables from within the
debugger.  Aka i = 0; if (i) printf ("Hello"); setting i = 1 in gdb
before the branch doesn't work when optimizing (it usually does when
not optimizing).

Reply via email to