Regarding the C programming language...
Part of the question at C/C++ Structure offset states that "& does not always point at the first byte of the first field of the structure"
But looking over the "ANSI Rationale" at http://www.lysator.liu.se/c/rat/c5.html it states "no hole may occur at the beginning" in section 3.5.2.1 Structure and union specifiers. So I'm not sure if the "Rationale" is definitive but it does seem to contradict that part of that highly visible question.
So, which is it? Is the first field of a C structure always guaranteed to be at offsetof 0?
struct A
{
int x;
};
struct B
{
struct A myA;
int y;
};
B myB;
Is &myB
guaranteed to be the same as &(myB.myA)
in a portable way?
(More concretely, the libev user-data trick at Libev, How to pass arguments to relevant callbacks and many other places does assume that the first field in the structure is at offsetof 0... is that really portable?)
From the C99 standard section 6.7.2.1 bullet point 13:
The answer to your question is therefore yes.