https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85033

--- Comment #5 from Marek Polacek <mpolacek at gcc dot gnu.org> ---
(In reply to Jakub Jelinek from comment #3)
> Started to ICE with r82549 when __builtin_offsetof has been introduced.
> 
> Wouldn't
> error: ‘struct <anonymous>’ has no member named ‘a’
> that the C FE emits be better?  

That's exactly what I tried the first time.  But lookup in C/C++ is different,
in C++ it happily finds 'X' in

struct S {
    enum { X };
};

int
foo (struct S s)
{
  return s.X;
}

unlike the C FE.  I admit I didn't know this was possible.

> Or is a still a member of the struct in C++,
> just not a non-static data member?
> Though, for
> int c = __builtin_offsetof(struct S { static int i; }, i);
> we emit
> error: cannot apply ‘offsetof’ to static data member ‘S::i’
> so perhaps your message is more descriptive.

We'll see on the ML what others think.

Reply via email to