[omniORB] Visual Studio 32-bit compiler error in httpContext.cc [Patch]

Daniel Krügler daniel.kruegler at gmail.com
Wed Feb 14 17:01:18 UTC 2024


Hi,

We recently tried to activate CORBA SSL and build OmniORB (4.3.2)
according to the instructions. It should be pointed out that we also
compiled the code against C++20.

When doing so, the build worked fine except for the 32-bit build using
Visual Studio 2022, which produced the following error:

httpContext.cc
httpContext.cc(259): error C2666: '_CORBA_String_var::operator []':
overloaded functions have similar conversions
D:\_DEV\git\net.sourceforge.omniorb\target\build32\omniORB-4.3.2\include\omniORB4/stringtypes.h(150):
note: could be 'char _CORBA_String_var::operator [](_CORBA_ULong)
const'
D:\_DEV\git\net.sourceforge.omniorb\target\build32\omniORB-4.3.2\include\omniORB4/stringtypes.h(143):
note: or       'char &_CORBA_String_var::operator [](_CORBA_ULong)'
httpContext.cc(259): note: or       'built-in C++ operator[](char *, int)'
httpContext.cc(259): note: or       'built-in C++ operator[](const char *, int)'

This ambiguity is understandable, since for the Windows compiler CORBA::ULong is
unsigned long and the affected code uses an int argument for the
operator[] call and on 32-bit ptrdiff_t is a typedef to int for this
standard library vendor. The right fix seems to be to effectively use
a CORBA::ULong argument for the operator[] invocation. We have applied
the attached patch and the library built successfully for Visual
Studio 2022, 2019 (32-bit and 64-bit) as well as gcc12 and gcc13 (each
64-bit). We would like to suggest to apply it to the main branch.

Thanks,

Daniel Krügler
-------------- next part --------------
diff --git "a/build/omniORB-4.3.2/src/lib/omniORB/orbcore/http/httpContext.cc" "b/build/omniORB-4.3.2/src/lib/omniORB/orbcore/http/httpContext.cc"
index 4a2f287..3328444 100644
--- "a/build/omniORB-4.3.2/src/lib/omniORB/orbcore/http/httpContext.cc"
+++ "b/build/omniORB-4.3.2/src/lib/omniORB/orbcore/http/httpContext.cc"
@@ -256,7 +256,7 @@ httpContext::b64decode(const char* data, size_t& len) {
   if (l < 0)
     OMNIORB_THROW(MARSHAL, MARSHAL_InvalidBase64Data, CORBA::COMPLETED_NO);

-  out[l] = '\0';
+  out[(CORBA::ULong)l] = '\0';

   len = (size_t)l;
   return out._retn();



More information about the omniORB-list mailing list