]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw_file.h: Clang has a more rigid requirement for definition.
authorWillem Jan Withagen <wjw@digiware.nl>
Tue, 17 May 2016 17:48:37 +0000 (19:48 +0200)
committerWillem Jan Withagen <wjw@digiware.nl>
Wed, 25 May 2016 10:13:00 +0000 (12:13 +0200)
 The ODR-used in [1] indicates that ODR-used does not result in the
 definition of the variable...

The definition is:
class class RGWFileHandle {
  static constexpr uint32_t FLAG_NONE =    0x0000;
}

And in this case, quoted from: Chefu Chai:
  because the constructor of std::tuple<> always passes its
  parameters by reference if possible and the values of its
  parameters are evaluated, RGWFileHandle::FLAG_NONE is ODR-used[1].
  but RGWFileHandle::FLAG_NONE out side of the class is not found
  anywhere. this fails the linker. so we should convert this lvalue
  to rvalue manually: uint32_t(RGWFileHandle::FLAG_NONE) when
  passing it to the ctor.

So the transformation to a rvalue allow of const evaluation, and thus
a definition of the varaible is no longer needed.

Otherwise without the cast this will result, during linking, in:
./.libs/librgw.so: undefined reference to `rgw::RGWFileHandle::FLAG_NONE'
clang++: error: linker command failed with exit code 1

 "[1] http://en.cppreference.com/w/cpp/language/definition"

Reviewed-by: kefu Chai <tchaikov@gmail.com>
Signed-off-by: Willem Jan Withagen <wjw@digiware.nl>
src/rgw/rgw_file.h

index 42b6649105187a18b75f84be369c93ce91eebc98..f056b6e2dc2c7edb0a637cf48f9489c085d5fb64 100644 (file)
@@ -802,7 +802,10 @@ namespace rgw {
                             const uint32_t flags = RGWFileHandle::FLAG_NONE) {
       using std::get;
 
-      LookupFHResult fhr { nullptr, RGWFileHandle::FLAG_NONE };
+      // cast int32_t(RGWFileHandle::FLAG_NONE) due to strictness of Clang 
+      // the cast transfers a lvalue into a rvalue  in the ctor
+      // check the commit message for the full details
+      LookupFHResult fhr { nullptr, uint32_t(RGWFileHandle::FLAG_NONE) };
 
       /* mount is stale? */
       if (state.flags & FLAG_CLOSED)