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: "kevin dot hendricks at sympatico dot ca" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Jul 2003 00:59:50 -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
------- Additional Comments From kevin dot hendricks at sympatico dot ca 2003-07-08 00:59 -------
Subject: Re: [3.3/3.4 regression] mozilla-1.4 miscompiled
Hi,
Thanks for explaining that. Now that I am aware of which parts
of the program the code generation is sensitive to, I have been able to take
the test case and hack away the C and Safe classes and remove the getter()
function and still see the problem.
Here is yet again a smaller testcase and my last so I hope this helps.
I am still not sure if this is an aliasing problem or not.
Perhaps the developer who wrote the nsCOMPtr template class for
Netscape / Mozilla can provide some insight into this problem?
cat tcase4.cxx
#include <cstdlib>
#include <cstdio>
class Iface {
public:
virtual int Add(void) = 0;
};
class M : public Iface {
public:
int i;
int Add(void) { i++; return i; }
int SetMutable(int k) { i = k; }
};
class Bbase {
public:
Bbase( Iface * rawPtr = 0) { a = rawPtr; }
void assign( Iface * q ) { a = q; }
#ifdef ALL_INTERNAL
void ** begin_assign()
{
assign(0);
return reinterpret_cast< void **> (&a);
}
#else
void ** begin_assign();
#endif
protected:
Iface * a;
};
#ifndef ALL_INTERNAL
void ** Bbase::begin_assign()
{
assign(0);
return reinterpret_cast< void **> (&a);
}
#endif
class B : private Bbase {
public:
B(): Bbase(0) {}
B( M* ptr ) : Bbase(ptr) {}
M** StartAssign() { return reinterpret_cast< M**> (begin_assign()); }
M* get () const { return reinterpret_cast< M* > (a); }
operator M*() const { return get(); }
M* operator->() const { return get(); }
};
int
main(int argc, char** argv)
{
B b1 = new M();
Iface * p=static_cast< Iface* >(b1);
B b2;
M** retval = b2.StartAssign();
*retval = static_cast< M* >(p);
b2->SetMutable(0);
fprintf(stderr,"done\n"); fflush(stderr);
return 0;
}