What does the C standard say about pointers to structs and their first member?
Posted
by James Morris
on Stack Overflow
See other posts from Stack Overflow
or by James Morris
Published on 2010-06-13T08:34:45Z
Indexed on
2010/06/13
8:42 UTC
Read the original article
Hit count: 223
Consider the following two struct
:
struct a
{
int a;
};
struct b
{
struct a a_struct;
int b;
};
the following instantiation of struct b
:
struct b b_struct;
and this condition:
if (&b_struct == (struct b*)&b_struct.a_struct)
printf("Yes\n");
Does the C standard mandate this to always evaluate true?
© Stack Overflow or respective owner