This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/29286] [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should
- From: "gdr at cs dot tamu dot edu" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 22 May 2007 16:25:26 -0000
- Subject: [Bug libstdc++/29286] [4.0/4.1/4.2/4.3 Regression] placement new does not change the dynamic type as it should
- References: <bug-29286-10053@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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