diff options
Diffstat (limited to 'gcc/testsuite/gcc.c-torture/execute/pr41935.c')
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr41935.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/gcc/testsuite/gcc.c-torture/execute/pr41935.c b/gcc/testsuite/gcc.c-torture/execute/pr41935.c new file mode 100644 index 000000000..ef8d08ce0 --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr41935.c @@ -0,0 +1,25 @@ +/* PR middle-end/41935 */ + +extern void abort (void); + +long int +foo (int n, int i, int j) +{ + typedef int T[n]; + struct S { int a; T b[n]; }; + return __builtin_offsetof (struct S, b[i][j]); +} + +int +main (void) +{ + typedef int T[5]; + struct S { int a; T b[5]; }; + if (foo (5, 2, 3) + != __builtin_offsetof (struct S, b) + (5 * 2 + 3) * sizeof (int)) + abort (); + if (foo (5, 5, 5) + != __builtin_offsetof (struct S, b) + (5 * 5 + 5) * sizeof (int)) + abort (); + return 0; +} |