[Bug tree-optimization/97236] [10/11 Regression] g:e93428a8b056aed83a7678 triggers vlc miscompile

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Tue Sep 29 13:46:26 GMT 2020


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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
typedef unsigned char __uint8_t;
typedef __uint8_t uint8_t;
typedef struct plane_t {
  uint8_t *p_pixels;
  int i_lines;
  int i_pitch;
} plane_t;

typedef struct {
  plane_t p[5];
} picture_t;

#define N 4

void __attribute__((noipa))
picture_Clone(picture_t *picture, picture_t *res)
{
  for (int i = 0; i < N; i++) {
    res->p[i].p_pixels = picture->p[i].p_pixels;
    res->p[i].i_lines = picture->p[i].i_lines;
    res->p[i].i_pitch = picture->p[i].i_pitch;
  }
}

int
main()
{
  picture_t aaa, bbb;
  uint8_t pixels[10] = {1, 1, 1, 1, 1, 1, 1, 1};

  for (unsigned i = 0; i < N; i++)
    aaa.p[i].p_pixels = pixels;

  picture_Clone (&aaa, &bbb);

  uint8_t c;
  for (unsigned i = 0; i < N; i++)
    c += bbb.p[i].p_pixels[0];

  if (c != N)
    __builtin_abort ();
  return 0;
}

ends up with a NULL pointer in bb.p[1].p_pixels


More information about the Gcc-bugs mailing list