Please consider the following code:
typedef struct {
int base_value;
} Base;
typedef struct {
Base base;
int child_value;
} Child;
Base* base = get_thing();
Child* child = (Child*) base;
Is the following guaranteed to always work, or is it implementation-dependent?
printf("%d", child->base_value);
Please note I'm not going through base
first (child->base.base_value
), but going directly to base_value
.