Hello,
Hodor here.
In the code fragment below is there any behaviour that is not defined?
Code:
#include <stdio.h>
struct foo {
int a, b;
};
struct bar {
struct foo coord;
const char *description;
};
void init(struct foo *p)
{
p->a = 42;
p->b = 84;
}
int main(void)
{
struct bar obj;
struct foo *p;
struct bar *p2;
init((struct foo *) &obj);
obj.description = "test";
p = (struct foo *) &obj;
p2 = (struct bar *)p;
printf("%d %d %s\n", p2->coord.a, p2->coord.b, p2->description);
return 0;
}
Edit: I'm not asking whether or not there is any "dangerous" behaviour by the way, I'm only interested in conformance (or not) with the C Standard.