1 struct A {
2 int a[1];
3 int b;
4 };
5
6 extern int c;
7
8 static int o[] = {
9 [__builtin_offsetof(struct A, b)] = 0, // OK
10 [__builtin_offsetof(struct A, a[0])] = 0, // OK
11 [__builtin_offsetof(struct A, a[0*0])] = 0, // OK
12 [__builtin_offsetof(struct A, a[c])] = 0 // KO
13 };
14
15 /*
16 * check-name: __builtin_offsetof() constness verification.
17 *
18 * check-error-start
19 constexpr-offsetof.c:12:39: error: bad constant expression
20 * check-error-end
21 */
|
1 struct A {
2 int a[1];
3 int b;
4 };
5
6 extern int c;
7
8 static int o[] = {
9 [__builtin_offsetof(struct A, b)] = 0, // OK
10 [__builtin_offsetof(struct A, a[0])] = 0, // OK
11 [__builtin_offsetof(struct A, a[0*0])] = 0, // OK
12 [__builtin_offsetof(struct A, a[c])] = 0 // KO
13 };
14
15 /*
16 * check-name: constexprness __builtin_offsetof()
17 *
18 * check-error-start
19 constexpr-offsetof.c:12:39: error: bad constant expression
20 * check-error-end
21 */
|