"mark at codesourcery dot com" <[EMAIL PROTECTED]> writes:

| > Indeed, consider this:
| > 
| >    // tu-2.C
| >    void f(int*);
| >    void g() {
| >       union {
| >         int i;
| >         double d;
| >       } t;
| > 
| >      t.i = 42;
| >      f(&t);
| >      cout << t.d << endl;
| >    }
| > 
| > I believe we can all agree the definition of g is valid.
| 
| No, I do not.  And GCC historically has not; you are only allowed to use
| the union for type-punning if the accesses are through the union
| directly. 

I am not talking of the GCC's historical behaviour here, but what the
standard actually says.  For the object "t", above the last write was
to the double field, therefore the read is well-defined.

-- Gaby

Reply via email to