mongo-cxx-driver
mongo-cxx-driver copied to clipboard
CXX-3088 fix build with GCC 4.8.5
Summary
Fix build with GCC 4.8.5.
Verified with this patch build.
Description
Supporting build with GCC 4.8.5 is motivated by a request to build on a customer RHEL 7.9 system. See slack thread.
This PR resolves errors observed when building with RHEL 7 with GCC 4.8.5.
Error: redeclaration differs in 'constexpr'
/root/mongo-cxx-driver/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp:571:45: error: redeclaration 'bsoncxx::v_noabi::stdx::basic_string_view<Char, Traits>::npos' differs in 'constexpr'
const std::size_t basic_string_view<C, Tr>::npos;
^
/root/mongo-cxx-driver/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/stdx/string_view.hpp:136:32: error: from previous declaration 'bsoncxx::v_noabi::stdx::basic_string_view<Char, Traits>::npos'
static constexpr size_type npos = static_cast<size_type>(-1);
I expect this is a quirk in old GCC. See: https://stackoverflow.com/a/17074539/774658. This PR adds constexpr to match.
Error: missing space
/root/mongo-cxx-driver/src/bsoncxx/include/bsoncxx/v_noabi/bsoncxx/json.hpp:83:42: error: missing space between '""' and suffix identifier
BSONCXX_API document::value BSONCXX_CALL operator""_bson(const char* json, size_t len);
This PR adds a space for C++11 compliance.
C++11 user-defined literals note a space is required:
float operator ""E(const char*); // error: ""E (with no intervening space) // is a single token
C++14 user-defined literals permit no space:
float operator ""_e(const char*); // OK
Ignoring unused parameters
Building the C driver resulted in errors due to unused-parameter warnings:
../../_deps/mongo-c-driver-src/src/libbson/src/bson/bson-atomic.h:202:28: error: unused parameter 'order' [-Werror=unused-parameter]
static BSON_INLINE Type bson_atomic_##NamePart##_fetch (
This was addressed in CDRIVER-5673. However, trying to upgrade the C driver to include the fix resulted in test failures in In-Use Encryption tests due to "rangePreview" being removed. I expect the In-Use Encryption test updates will be addressed in CXX-3014. To limit scope of this PR, -Wno-unused-parameter is added to compile flags on RHEL 7 as a temporary workaround until the C driver is upgraded to include CDRIVER-5673.