[omniORB] omniORB2 with Borland C++ Builder app => Compilation Errors!!!

David Morgenlender dmorgen@alum.mit.edu
Thu, 16 Apr 1998 23:59:29 GMT


Sai-Lai,

>I gave it a go and got the omniORB2 runtime and the echo examples to
>compile under Borland C++ 5.0 (I don't have the C++ builder). eg1 works.
>eg2_clt seems to work with eg2_impl but eg2_impl immediately exits after
>the first eg2_clt invocation. Running eg3_impl give me access violation.
>
>I think the problem with the binaries are related to a bug I encountered
>with this C++ compiler. Basically, the Borland compiler confuses enum =
type
>with int when choosing an overloaded operator. This is illustrated with =
the
>following examples:
>
>wib.cc shows that Borland C++ is picking up the wrong operator>>=3D.
>
>It fails to compile wob.cc because of the same confusion.
>
>I'm going to pack up what I've done and let you have a go.
>But first it is worth checking if the same bug occurs in C++ builder 3.
>If it is still there then this could be a showstopper.

I just ran both WIB.CC & WOB.CC from README.BCC through Borland C++ =
Builder 3.
The good news is that WOB.CC at least seemed to compile ok.

The bad news is that while WIB.CC seemed to compile ok, bad code was =
generated.
Not only does the compiler use the wrong type when using an overloaded =
operator
for an enum, but are there problems handling overloaded operators for
streams/strings ... it's handled wrong in main(), but ok in some other
functions!

Something else I wonder about ... remember the original problems I =
reported ...
BCB3 reported "lvalue required" errors on some enum assignments.  I can't=
 find
any overloaded operator=3D that would apply here.  But I wonder if this =
is a
similar case of  compiler confusion on overloaded operators.

I'll report these new problems to Borland.  But I doubt there will be a =
quick
resolution. =20

Do you see any hope for getting omniORB2 ported to BCB3 in the near term,=
 or
should I look for another orb?

Thanks for your help with this!


-------------------------------------------------------------------------=
---------------------------

// WIB.CPP

// This demonstrates at least 2 BCB3 compiler bugs:
// 1.	As described in main(), statements of the following format are
//	miscompiled in the main() function only:
//		cerr << "string";
// 2.	The overloaded >>=3D operator is not called for enums;
//	instead the overloaded >>=3D operator for long is called!!!

#pragma hdrstop
#include <condefs.h>

#pragma argsused

#include <iostream.h>

class S {
public:
  S() {}
  ~S() {}
};


// This is always called for >>=3D in main()!!!
void operator>>=3D(long a, S& s)
{
  cerr << "operator>>=3D(long a, S& s)" << endl;
}

namespace X {
  enum E { E_1, E_2 };
  void operator>>=3D(E a, S& s);

  class I {
  public:
    enum F { F_1, F_2 };

    // This is never called for >>=3D in main()!!!
    friend void operator>>=3D(F a, S& s)
    {
      cerr << "operator>>=3D(F a, S& s)" << endl;
    }
  };
}

// This is never called for >>=3D in main()!!!
void X::operator>>=3D(X::E a, S& s)
{
  cerr << "operator>>=3D(E a, S& s)" << endl;
}


int
main(int,char**)
{
	long m =3D 1;
	X::E n =3D X::E_2;
	X::I::F o =3D X::I::F_1;
	S s;

	// Treats strings in both versions of the following as "void*",
	// thus outputting pointer values instead of strings.
	// Yet, in the above functions, it works ok!
	// Casting to "const char*" generates a compile error.
	// Casting to "char*" is treated as "void*".
#if 0
	cerr << "Expected output:\n"
			<< "   operator>>=3D(long a, S& s)\n"
			<< "   operator>>=3D(E a, S& s)\n"
			<< "   operator>>=3D(F a, S& s)" << endl;
	cerr << "\nActual output:" << endl;
#endif

	cerr << "Expected output:" << endl;
	cerr		<< "   operator>>=3D(long a, S& s)" << endl;
	cerr		<< "   operator>>=3D(E a, S& s)" << endl;
	cerr		<< "   operator>>=3D(F a, S& s)" << endl;
	cerr << "\nActual output:" << endl;

	m >>=3D s;
	n >>=3D s;
	o >>=3D s;
	return 0;
}

=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D
Dave Morgenlender
e-mail: dmorgen@alum.mit.edu
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D