[Bug tree-optimization/108398] tree-object-size trips up with pointer arithmetic if an intermediate result is an invalid pointer

yann at droneaud dot fr gcc-bugzilla@gcc.gnu.org
Fri Jan 13 19:52:19 GMT 2023


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

Yann Droneaud <yann at droneaud dot fr> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |yann at droneaud dot fr

--- Comment #6 from Yann Droneaud <yann at droneaud dot fr> ---
c-reduce comes up with the following reproducer:

  #include <string.h>
  typedef struct {
    int a;
  } b;
  typedef struct {
    b c[2];
  } d;
  d e;
  int f = 2;
  int main() {
    b *g;
    for (g = e.c; f; g++)
      switch (g->a) {
      case 0:
        memmove(g, g + 1, sizeof(b));
        f--;
        g--;
      }
   }

gcc -fsanitize=undefined doesn't catch any issue ...


More information about the Gcc-bugs mailing list