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



------- Additional Comments From kevin dot hendricks at sympatico dot ca  2003-07-08 17:34 -------
Subject: Re:  [3.3/3.4 regression] mozilla-1.4 miscompiled

Hi,

> Unless someone doesn't think Mark is correct, this bug should be 
> closed, as the
> code is invalid C++.

If it is an aliasing issue, changing the test case in this way

struct A {
   virtual int Setit(int k) = 0;
};

struct B : A {
     int Setit(int k) { int i; i = k; }
};

A* a;
void ** begin_assign() { return reinterpret_cast< void **> (&a); }

int
main(int argc, char** argv)
{

#if 0
     B** ppB = reinterpret_cast<B**> (begin_assign());
     *ppB = new B();
#else
     A** ppB = reinterpret_cast<A**> (begin_assign());
     *ppB = new B();
#endif

     a->Setit(0);
     return 0;
}

Since *ppB will be a A* which can hold a B* legally, it should prevent
any aliasing problem.

I tested this case and sure enough it compiles and runs at
all optimization levels just fine.

So it sure looks like an aliasing issue to me.

I agree  this should be closed and a bug against Mozilla nsCOMPtr<> 
code should be opened.

Franz?  What do you think?


Kevin


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