MongoDB C++11 Driver 4.3.0 Released

The MongoDB C++ Driver Team is pleased to announce the availability of MongoDB C++ Driver 4.3.0.

Please note that this version of mongocxx requires MongoDB C Driver 2.3.0 or newer.

See the MongoDB C++ Driver Manual and the Driver Installation Instructions for more details on downloading, installing, and using this driver.

NOTE: The mongocxx 4.3.x series does not promise API or ABI stability across patch releases.

Please feel free to post any questions on Stack Overflow. Bug reports should be filed against the CXX project in the MongoDB JIRA. Your feedback on the C++11 driver is greatly appreciated.

Sincerely,

The C++ Driver Team

When trying to update from 4.1.4 to 4.3.0, compilations failed due to lack of RTTI:

../../../../../../../../../../objectbox/src/main/cpp/external/mongo-cxx-driver/src/mongocxx/lib/mongocxx/v_noabi/mongocxx/mongoc_error.hh:111:26: error: use of dynamic_cast requires -frtti
 111 | if (auto const ptr = dynamic_cast<v1::server_error const*>(&ex)) {
 | ^
1 error generated.

Is using dynamic_cast an oversight there, or is RTTI now required?

P.S.: To clarify, we disable RTTI in some configurations and it has worked without in mongocxx for many versions.

This is the commit: v1::exception and v1::server_error (CXX-3237, CXX-3238) (#1501) · mongodb/mongo-cxx-driver@82f77b6 · GitHub

And looking at the code in question, it seems to be some kind of exception mapping:

template <typename exception_type>
[[noreturn]] void throw_exception(v1::exception const& ex) {
    if (auto const ptr = dynamic_cast<v1::server_error const*>(&ex)) {
        throw exception_type{
            ptr->code(), bsoncxx::v_noabi::document::value{bsoncxx::v_noabi::from_v1(ptr->raw())}, ptr->what()};
    }

    throw exception_type{ex.code(), ex.what()};
}

Maybe the dynamic cast could be avoided by overloading with a v1::server_error parameter - if callers still have the full type info.

Also, just for my personal curiosity, why does this exception mapping happen in the first place?

Hi Markus, thank you for reporting. I created CXX-3483 to track investigating. Please continue the conversation there. Community Hub is more focused on announcements (per Announcing Changes to the MongoDB Community Forum ). The CXX Jira tracks bug reports and feature requests.

1 Like

This topic was automatically closed after 90 days. New replies are no longer allowed.