Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1047

MSVC warning C4714, bsoncxx operator <<, view() etc. marked as __forceinline not inlined

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.1.0
    • Affects Version/s: 3.0.2
    • Component/s: BSON
    • None

      In MSVC 2015U3, the compiler is unable to inline some bsoncxx functions.

      Try compiling the following with /O2 /W4 (warning level 4):

      #include <bsoncxx/builder/stream/document.hpp>
      #include <bsoncxx/json.hpp>
      #include <iostream>
      
      using namespace bsoncxx::builder::stream;
      
      int main() {
        document doc;
        doc << "test" << "test";
        auto doc_val = doc << finalize;
        std::cout << bsoncxx::to_json(doc_val.view()) << std::endl;
      }
      

      Output:

      1>ctest.cpp(13): warning C4714: function 'bsoncxx::v_noabi::document::value bsoncxx::v_noabi::builder::stream::key_context<bsoncxx::v_noabi::builder::stream::closed_context>::operator <<<const bsoncxx::v_noabi::builder::stream::finalize_type&>(T)' marked as __forceinline not inlined
      1>          with
      1>          [
      1>              T=const bsoncxx::v_noabi::builder::stream::finalize_type &
      1>          ]
      1>  ..\bsoncxx/builder/stream/key_context.hpp(131): note: see declaration of 'bsoncxx::v_noabi::builder::stream::key_context<bsoncxx::v_noabi::builder::stream::closed_context>::operator <<'
      1>  Generating code
      1>..\bsoncxx\document\value.hpp(109): warning C4714: function 'class bsoncxx::v_noabi::document::view __cdecl bsoncxx::v_noabi::document::value::view(void)const __ptr64' marked as __forceinline not inlined
      

            Assignee:
            david.golden@mongodb.com David Golden
            Reporter:
            rustyx Rustam Abdullaev
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: