title: Nested structs and strict aliasing in c
body: <p>Please consider the following code:</p>
  
  <pre><code>typedef struct {
    int type;
  } object_t;
  
  typedef struct {
    object_t object;
    int age;
  } person_t;
  
  int age(object_t *object) {
    if (object-&gt;type == PERSON) {
      return ((person_t *)object)-&gt;age;
    } else {
      return 0;
    }
  }
  </code></pre>
  
  <p>Is this legal code or is it violating the C99 strict aliasing rule? Please explain why it is legal/illegal.</p>