This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: Fix PR 13275
> #include <stddef.h>
>
> struct A {
> static int a;
> static A b;
> };
>
> int A::a;
> A A::b;
>
> struct B : A {
> };
>
> int main() {
> offsetof(A, a); // should be an ERROR
> offsetof(B, A::b); // ditto
> }
These are both undefined behavior. No diagnostic is required.
And, if you want an error message, that's easy. Just modify
cp_parser_postfix_expression to pass in_offsetof_p down to
finish_class_member_access_expr. That's *exactly the same* work you'd
have to do in builtin_offsetof anyhow.
Since you think arguing about this is a good use of your time, I can
only conclude that V3 is now bug-free and as fast as possible! I am
overjoyed. :-)
--
Mark Mitchell <mark@codesourcery.com>
CodeSourcery, LLC