This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/11376] [3.3/3.4 regression] mozilla-1.4 miscompiled
- From: "giovannibajo at libero dot it" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 7 Jul 2003 15:46:37 -0000
- Subject: [Bug c++/11376] [3.3/3.4 regression] mozilla-1.4 miscompiled
- References: <20030630081619.11376.sirl@gcc.gnu.org>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=11376
giovannibajo at libero dot it changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |mmitchel at gcc dot gnu dot
| |org, nathan at gcc dot gnu
| |dot org
------- Additional Comments From giovannibajo at libero dot it 2003-07-07 15:46 -------
I believe the code is not legal. In main(), getter_addRefs calls
nsGetterAddRefs<mc0> constructor, which calls nsComPtr<mc0>::StartAssignment.
This function calls begin_assignment which casts &mRawPtr (whose type is
nsiSupports**) to void** through reinterpret_cast. Then, this void** is casted
to mc0** through reinterpret_cast. Now, mc0 is derived from nsiSupports. In
short, this looks like:
struct A {};
struct B : A {};
A* a;
void** pv = reinterpret_cast<void**>(&a);
B** pb = reinterpret_cast<B**>(pv);
*pb = new B;
assert (typeid(*a) == typeid(B));
I believe this violates ISO C++ aliasing rules, but I don't have a standard
handy to double-check now.
Kevin, can you please confirm that my snippet follows the code correctly?
Nathan, do you think the code is legal?