[CXX-940] Default constructed bsoncxx::oid object is dangerous Created: 19/Jun/16  Updated: 19/Sep/16  Resolved: 15/Jul/16

Status: Closed
Project: C++ Driver
Component/s: API
Affects Version/s: None
Fix Version/s: 3.0.2

Type: Bug Priority: Major - P3
Reporter: Andrew Morrow (Inactive) Assignee: Backlog - CXX Driver Team
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related

 Description   

See https://groups.google.com/forum/?utm_medium=email&utm_source=footer#!msg/mongodb-user/25T40eHhAMg/xIgyOoUVCQAJ



 Comments   
Comment by Githook User [ 15/Jul/16 ]

Author:

{u'username': u'adamchel', u'name': u'Adam Chelminski', u'email': u'adam.chelminski@mongodb.com'}

Message: CXX-940 Deprecate bsoncxx::oid::init_tag and make bsoncxx::oid's default constructor do full OID initialization
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/c25e50b8b9353595d3f01bf9bb07d81a59416b8f

Comment by Andrew Morrow (Inactive) [ 13/Jul/16 ]

Code review: https://github.com/mongodb/mongo-cxx-driver/pull/506

Comment by Allan Bazinet [ 22/Jun/16 ]

With reference to the linked discussion, IMO an all-zero OID seems unnecessary given the plethora of better alternatives available; in general magic sentinel values tends to be something that one quickly regrets having gone with.

I think that the most common use case for expressly declaring an OID is that one, well, wants an OID, and it seems reasonable in that case to have it default-constructed to a usable state; I think to do otherwise is unexpected.

The optional approach in order to avoid the cost of such construction is certainly nice to have, but I suppose that I'd be surprised in the first place to find the cost to be non-trivial.

Comment by Andrew Morrow (Inactive) [ 22/Jun/16 ]

alb - We would also be interested in feedback on this issue. Please see the linked group discussion. We are considering removing the bsoncxx::oid::init_tag and making the class default constructible with the semantics of doing full OID initialization. The idea is that users needing to defer that cost could use bsoncxx::stdx::optional<bsoncxx::oid>.

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