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>
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)