llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

[clang] unexpected syntax error when __builtin_offsetof uses array dereference on member

Open agostonrobert opened this issue 4 years ago • 2 comments

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); }

agostonrobert avatar Jun 29 '22 06:06 agostonrobert

@llvm/issue-subscribers-clang-frontend

llvmbot avatar Jun 29 '22 15:06 llvmbot

@niwinanto is working on the issue, see https://reviews.llvm.org/D136843

agostonrobert avatar Nov 09 '22 07:11 agostonrobert