llvm-project
llvm-project copied to clipboard
[clang] unexpected syntax error when __builtin_offsetof uses array dereference on member
The last line in the following code is accepted by gcc but rejected by clang, although the same syntax is accepted for assignment even by clang.
typedef struct {
struct s {
int i;
} foo[1];
} my_t;
void access_both_works(my_t *m) {
m->foo->i = 0;
m->foo[0].i = 2;
}
int works_with_gcc_and_clang() { return __builtin_offsetof(my_t, foo[0].i); }
int does_not_work_with_clang() { return __builtin_offsetof(my_t, foo->i); }
@llvm/issue-subscribers-clang-frontend
@niwinanto is working on the issue, see https://reviews.llvm.org/D136843