resource-encapsulation: Avoid reinterpret_cast in const_expr
authorPhilippe Coval <philippe.coval@osg.samsung.com>
Fri, 9 Sep 2016 17:12:26 +0000 (19:12 +0200)
committerUze Choi <uzchoi@samsung.com>
Mon, 12 Sep 2016 03:54:46 +0000 (03:54 +0000)
As unsupported in C++11 standard and g++-6 or clang

Reported error message is:

  service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp:368:13:
  error: reinterpret_cast from integer to pointer
  reinterpret_cast<OCRequestHandle>(0x1234);

Problem was observed while building for Yocto with generic toolchain:
  i586-poky-linux-g++ (GCC) 6.2.0

For reference see p125 of:

  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3797.pdf

Change-Id: I20b21ad1bdac40c2aec44706501343ae1d9d7b69
Bug: https://jira.iotivity.org/browse/IOT-1111
Origin: https://github.com/tizenteam/meta-oic
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/11663
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Uze Choi <uzchoi@samsung.com>
service/resource-encapsulation/src/serverBuilder/unittests/RCSResourceObjectTest.cpp

index 3126912..8aa958d 100644 (file)
@@ -364,10 +364,8 @@ class ResourceObjectHandlingRequestTest: public ResourceObjectTest
 public:
     EntityHandler handler;
 
-    static constexpr OCRequestHandle fakeRequestHandle =
-            reinterpret_cast<OCRequestHandle>(0x1234);
-    static constexpr OCResourceHandle fakeResourceHandle =
-            reinterpret_cast<OCResourceHandle>(0x4321);
+    static const OCRequestHandle fakeRequestHandle;
+    static const OCResourceHandle fakeResourceHandle;
 
 public:
     OCResourceRequest::Ptr createRequest(OCMethod method = OC_REST_GET, OCRepresentation ocRep =
@@ -415,6 +413,11 @@ protected:
     }
 };
 
+const OCRequestHandle ResourceObjectHandlingRequestTest::fakeRequestHandle =
+    reinterpret_cast<OCRequestHandle>(0x1234);
+const OCResourceHandle  ResourceObjectHandlingRequestTest::fakeResourceHandle =
+    reinterpret_cast<OCResourceHandle>(0x4321);
+
 TEST_F(ResourceObjectHandlingRequestTest, CallSendResponseWhenReceiveRequest)
 {
     mocks.ExpectCallFunc(OCPlatform::sendResponse).Return(OC_STACK_OK);