[omniORB] MSVC 6.0 bug with inheritance across namespaces (mo dules)
Irfan Pyarali
irfan@cs.wustl.edu
Mon, 03 Aug 1998 14:59:52 -0500
Hi Dietmar:
> However, due to a separate bug in MSVC, X::dispatch() is not properly
> handled, and generates an (invalid and incorrect) compiler error.
> omniORB handles this using a typedef:
>
> typedef X::A X_A;
>
> Therefore:
>
> namespace Y
> {
> virtual retcode Y::dispatch (...)
> {
> if(strcmp(fname, "func2") == 0)
> func2();
> else
> X_A::dispatch(...); //note the use of typedef - not X::A::
> }
> }
>
> However, the MSVC compiler is creating object code as if the
> IDL-generated code were (but is NOT):
>
> virtual retcode Y::dispatch (...)
> {
> if(strcmp(fname, "func2") == 0)
> func2();
> else
> Y::A::dispatch(...); //oops, references current namespace
> }
>
> This is where the x86 assembly code comes in, to demonstrate that this
> is what the compiler is actually creating. When running this code, of
> course, since it is recursive, it eventually exhausts the stack and
> throws a runtime exception.
I tested the problem you described with the following example code,
but failed to see the incorrect behavior.
Can you please elaborate on the VC compiler problem or tell me how
this example is not representative of the real problem.
Thanks
Irfan
________________________________________
#include "iostream.h"
namespace X
{
class A
{
public:
virtual void dispatch ()
{
cout << "X::A::dispatch ()" << endl;
}
};
};
typedef X::A X_A;
namespace Y
{
class B : public X_A
{
public:
void dispatch ()
{
cout << "Y::B::dispatch ()" << endl;
X_A::dispatch ();
}
};
};
void
main ()
{
X_A *a = new Y::B;
a->dispatch ();
delete a;
Y::B *b = new Y::B;
b->dispatch ();
delete b;
}
Output:
Y::B::dispatch ()
X::A::dispatch ()
Y::B::dispatch ()
X::A::dispatch ()