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

--- Comment #2 from Stas Sergeev <stsp at users dot sourceforge.net> ---
(In reply to Jakub Jelinek from comment #1)
> Simplified testcase:
> struct A { char a; };
> struct B : public A { static constexpr int b = __builtin_offsetof (B, a); };
> 
> clang rejects this too, not really sure if it is valid or not.

Thanks for taking a look!
A slight off-topic: any idea why even this rejects:
struct A {
    char a;
    static constexpr int b = __builtin_offsetof (A, a);
};

and is there any work-around when I want to
pass offsetof value into a template non-type,
which also rejects:
struct A {
    char a;
    B<__builtin_offsetof(A, a)> b;
};

Does the standard explicitly forbids that, of just gcc?

Reply via email to