[CXX-1047] MSVC warning C4714, bsoncxx operator <<, view() etc. marked as __forceinline not inlined Created: 23/Sep/16  Updated: 08/Jan/24  Resolved: 17/Nov/16

Status: Closed
Project: C++ Driver
Component/s: BSON
Affects Version/s: 3.0.2
Fix Version/s: 3.1.0

Type: Bug Priority: Major - P3
Reporter: Rustam Abdullaev Assignee: David Golden
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified


 Description   

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



 Comments   
Comment by Githook User [ 29/Nov/16 ]

Author:

{u'username': u'xdg', u'name': u'David Golden', u'email': u'xdg@xdg.me'}

Message: CXX-1047 Remove force inline tags

They should be unnecessary since we already have the privacy tags and
cause warnings on MSVC if the function is too complex for inlining.
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/41770fc627f5787f8d437a0b31ec7b4a53b820cb

Comment by Githook User [ 17/Nov/16 ]

Author:

{u'username': u'xdg', u'name': u'David Golden', u'email': u'xdg@xdg.me'}

Message: CXX-1047 Remove force inline tags

They should be unnecessary since we already have the privacy tags and
cause warnings on MSVC if the function is too complex for inlining.
Branch: 3.1-dev
https://github.com/mongodb/mongo-cxx-driver/commit/41770fc627f5787f8d437a0b31ec7b4a53b820cb

Comment by David Golden [ 17/Nov/16 ]

https://mongodbcr.appspot.com/101770002/

Comment by David Golden [ 03/Nov/16 ]

Since we're about to ship 3.0.3, I'm moving this ticket out to 3.1 as I don't want to rush a fix.

Generated at Wed Feb 07 22:01:13 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.