modernc.org/ccgo/v3@v3.16.14/lib/testdata/gcc-9.1.0/gcc/testsuite/gcc.c-torture/execute/pr41935.c (about)

     1  /* PR middle-end/41935 */
     2  
     3  extern void abort (void);
     4  
     5  long int
     6  foo (int n, int i, int j)
     7  {
     8    typedef int T[n];
     9    struct S { int a; T b[n]; };
    10    return __builtin_offsetof (struct S, b[i][j]);
    11  }
    12  
    13  int
    14  main (void)
    15  {
    16    typedef int T[5];
    17    struct S { int a; T b[5]; };
    18    if (foo (5, 2, 3)
    19        != __builtin_offsetof (struct S, b) + (5 * 2 + 3) * sizeof (int))
    20      abort ();
    21    if (foo (5, 5, 5)
    22        != __builtin_offsetof (struct S, b) + (5 * 5 + 5) * sizeof (int))
    23      abort ();
    24    return 0;
    25  }