view gcc/testsuite/gcc.dg/pr41935.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children
line wrap: on
line source

/* PR middle-end/41935 */
/* { dg-do run } */
/* { dg-options "-O2" } */

extern void abort (void);
struct A { int a; int b[10]; };

int
foo (struct A *p)
{
  return __builtin_offsetof (struct A, b[p->a]);
}

int
main ()
{
  struct A a;
  a.a = 7;
  if (foo (&a) != 7 * sizeof (int) + __builtin_offsetof (struct A, b))
    abort ();
  a.a = 2;
  if (foo (&a) != 2 * sizeof (int) + __builtin_offsetof (struct A, b))
    abort ();
  return 0;
}