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 c++/11376] [3.3/3.4 regression] mozilla-1.4 miscompiled


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?


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