C11 related language correctness

Viewed 121

The following code snippet is an example from the C11 standard §6.5.2.3:

struct t1 { int m; };
struct t2 { int m; };
int f(struct t1 *p1, struct t2 *p2)
{
    if (p1->m < 0)
        p2->m = -p2->m;
    return p1->m;
}
int g()
{
    union {
        struct t1 s1;
        struct t2 s2;
    } u;
    /* ... */
    return f(&u.s1, &u.s2);
}

As per C11, the last line inside g() is invalid. Why so?

2 Answers
Related