Hello, The standard header <cstddef> provides the macro 'offsetof(type, member-designator)'. The current C++ ISO/IEC standard 14882 dictates, I believe, that 'type' should be a POD.
Recent versions of the working drafts have somewhat relaxed the requirements, introducing the concept of "Standard-Layout". The change was introduced in "http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2369.pdf" and was developed in the paper "POD's Revisited" regarding an issue reported to the standard ("Definition of POD is too strict"), in particular its second revision ( http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2172.html). I'd like to ask about the status or the consequences over GNU/gcc of that change in the standard. Nowadays I'm working with g++ (GCC) 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2) Actually trying and compiling ("g++ main.cc -o main") the following example: #include <cstddef> class A { //public: void f(){ offsetof(A,i); } int i; }; int main(){} causes the following warning message main.cc:4: warning: invalid access to non-static data member 'A::i' of NULL object main.cc:4: warning: (perhaps the 'offsetof' macro was used incorrectly) If the 'public' access control modifier is introduced (deleting the // at the beginning) no message is given. I suppose that in this particular case the warning may be ignored without risk, but in other cases may not. Are there any guarantees besides what's currently dictated by the standard? In particular, may 'offsetof' in GNU/gcc work properly with types that only respect the (new) requirement of having "standard-layout"? If so, does it happen in any particular version? Thanks a lot for your help. -- Rodolfo Federico Gamarra