[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: |
|
||||
| Description |
|
|
| 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: |
| 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>. |