Archived
This forum has been archived. Please start a new discussion on GitHub.
Ice 3.5.1: compatibility with Intel C++ 2015
alexmnazarenko
in Patches
Hi. We've managed to build a working version of Ice with intel compiler (On Win x64). It works with our (quite complex) app, so hopefully build is correct.
However, it required patch to Ice code which took a while to figure out. Everything just froze on connection establishment. Patch seems to be correct and harmless, so we suggest it to developers to apply in some later version to save trouble to other desperate Intel C++ users.
The problem is in subtle difference in overload selection. In a code:
Intel selects "bool&" overload without a warning. Ice source contains few overloads of this type (e.g. IceInternal::OutgoingConnectionFactory::create, Ice::Handle is similar to PtrT in example). The result is awful - pointer to callback gets casted to bool, callback is lost, application freezes.
Patch text:
However, it required patch to Ice code which took a while to figure out. Everything just froze on connection establishment. Patch seems to be correct and harmless, so we suggest it to developers to apply in some later version to save trouble to other desperate Intel C++ users.
The problem is in subtle difference in overload selection. In a code:
#include <iostream>
struct T {};
struct PtrT { PtrT(T*) {} };
void f(bool&) { std::cout << "FAIL - bool" << std::endl; }
void f(PtrT) { std::cout << "OK - PtrT" << std::endl; }
int main() {
f(new T);
}
Intel selects "bool&" overload without a warning. Ice source contains few overloads of this type (e.g. IceInternal::OutgoingConnectionFactory::create, Ice::Handle is similar to PtrT in example). The result is awful - pointer to callback gets casted to bool, callback is lost, application freezes.
Patch text:
--- cpp/src/Ice/Reference.cpp
+++ cpp/src/Ice/Reference.cpp
@@ -1666,7 +1666,7 @@
vector<EndpointIPtr> endpts = endpoints;
_reference->applyOverrides(endpts);
- _reference->createConnection(endpts, new Callback2(_reference, _callback, cached));
+ _reference->createConnection(endpts, GetConnectionCallbackPtr(new Callback2(_reference, _callback, cached)));
}
virtual void
@@ -1695,7 +1695,7 @@
if(_locatorInfo)
{
RoutableReference* self = const_cast<RoutableReference*>(this);
- _locatorInfo->getEndpoints(self, _locatorCacheTimeout, new Callback(self, callback));
+ _locatorInfo->getEndpoints(self, _locatorCacheTimeout, LocatorInfo::GetEndpointsCallbackPtr(new Callback(self, callback)));
}
else
{
@@ -1829,7 +1829,7 @@
// Get an existing connection or create one if there's no
// existing connection to one of the given endpoints.
//
- factory->create(endpoints, false, getEndpointSelection(), new CB1(_routerInfo, callback));
+ factory->create(endpoints, false, getEndpointSelection(), OutgoingConnectionFactory::CreateConnectionCallbackPtr(new CB1(_routerInfo, callback)));
return;
}
else
@@ -1904,7 +1904,7 @@
vector<EndpointIPtr> endpt;
endpt.push_back(endpoints[0]);
RoutableReference* self = const_cast<RoutableReference*>(this);
- factory->create(endpt, true, getEndpointSelection(), new CB2(self, endpoints, callback));
+ factory->create(endpt, true, getEndpointSelection(), OutgoingConnectionFactory::CreateConnectionCallbackPtr(new CB2(self, endpoints, callback)));
return;
}
}
0
Comments
-
Hi Alexey,
Thank you for this patch!
Could you please submit a pull request on GitHub, for the 3.5 branch or for the master branch (which will soon be 3.6)?
See https://github.com/zeroc-ice/ice/blob/master/CONTRIBUTING.md
Best regards,
Bernard0 -
0
