This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libstdc++/29286] [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should



------- Comment #110 from gdr at cs dot tamu dot edu  2007-05-22 17:25 -------
Subject: Re:  [4.0/4.1/4.2/4.3 Regression] placement new does not change the
dynamic type as it should

"mark at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org> 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


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29286


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]