For some reason, this code runs (!) but with the raised error if I do not add inline. And works fine, otherwise. Why so?
#include <iostream>
#define NAME b
template <typename T>
struct B {
static const ptrdiff_t shift = offsetof(T, NAME); // it runs (!) but gives an error
// inline static const ptrdiff_t shift = offsetof(T, NAME); // works fine
};
struct A {
B<A> b;
};
int main() {
return 0;
}
offsetof is underlined with a red squiggly line:
Offsetof of incomplete type 'A'clang(offsetof_incomplete_type)