From: Willem Jan Withagen Date: Tue, 17 May 2016 17:48:37 +0000 (+0200) Subject: rgw_file.h: Clang has a more rigid requirement for definition. X-Git-Tag: v11.0.0~319^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4e0c668d4eb388357c59d1467c353e44146d1c7f;p=ceph.git rgw_file.h: Clang has a more rigid requirement for definition. 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 Signed-off-by: Willem Jan Withagen --- diff --git a/src/rgw/rgw_file.h b/src/rgw/rgw_file.h index 42b66491051..f056b6e2dc2 100644 --- a/src/rgw/rgw_file.h +++ b/src/rgw/rgw_file.h @@ -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)