Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-39327

BSONObjBuilder::append() should generate the same compile errors with all toolchains

    • Type: Icon: Improvement Improvement
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Dev Tools 2019-02-11
    • 0

      If you pass a long type to BSONObjBuilder::append() on macOS, the following compile error is generated because the argument is ambiguous.

      This causes unnecessary compile failures on non-required builders like macOS for no reason. My suggestion is one of the following:
      a. The toolchain on required builders should also generate this same error
      b. Modify BSONObjBuilder::append() so that passing a long type is not ambiguous on macOS.

       [2019/02/01 01:08:20.279] src/mongo/db/storage/bson_collection_catalog_entry.cpp:308:17: error: call to member function 'append' is ambiguous
       [2019/02/01 01:08:20.279]             sub.append("versionOfBuild", indexes[i].versionOfBuild);
       [2019/02/01 01:08:20.279]             ~~~~^~~~~~
       [2019/02/01 01:08:20.279] src/mongo/bson/bsonobjbuilder.h:281:21: note: candidate function
       [2019/02/01 01:08:20.279]     BSONObjBuilder& append(StringData fieldName, bool val) {
       [2019/02/01 01:08:20.279]                     ^
       [2019/02/01 01:08:20.279] src/mongo/bson/bsonobjbuilder.h:289:21: note: candidate function
       [2019/02/01 01:08:20.279]     BSONObjBuilder& append(StringData fieldName, int n) {
       [2019/02/01 01:08:20.279]                     ^
       [2019/02/01 01:08:20.280] src/mongo/bson/bsonobjbuilder.h:297:21: note: candidate function
       [2019/02/01 01:08:20.280]     BSONObjBuilder& append(StringData fieldName, unsigned n) {
       [2019/02/01 01:08:20.280]                     ^
       [2019/02/01 01:08:20.280] src/mongo/bson/bsonobjbuilder.h:311:21: note: candidate function
       [2019/02/01 01:08:20.280]     BSONObjBuilder& append(StringData fieldName, long long n) {
       [2019/02/01 01:08:20.280]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:387:21: note: candidate function
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, double n) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:212:21: note: candidate function not viable: no known conversion from 'const long' to 'mongo::BSONObj' for 2nd argument
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, BSONObj subObj) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:260:21: note: candidate function not viable: no known conversion from 'const long' to 'mongo::BSONArray' for 2nd argument
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, BSONArray arr) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:302:21: note: candidate function not viable: no known conversion from 'const long' to 'mongo::Decimal128' for 2nd argument
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, Decimal128 n) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:419:21: note: candidate function not viable: no known conversion from 'const long' to 'mongo::OID' for 2nd argument
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, OID oid) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:449:21: note: candidate function not viable: no known conversion from 'const long' to 'mongo::Date_t' for 2nd argument
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, Date_t dt) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:465:21: note: candidate function not viable: no known conversion from 'const long' to 'const mongo::BSONRegEx' for 2nd argument
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, const BSONRegEx& regex) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.281] src/mongo/bson/bsonobjbuilder.h:477:21: note: candidate function not viable: no known conversion from 'const long' to 'const mongo::BSONCode' for 2nd argument
       [2019/02/01 01:08:20.281]     BSONObjBuilder& append(StringData fieldName, const BSONCode& code) {
       [2019/02/01 01:08:20.281]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:491:21: note: candidate function not viable: no known conversion from 'const long' to 'const char *' for 2nd argument
       [2019/02/01 01:08:20.282]     BSONObjBuilder& append(StringData fieldName, const char* str) {
       [2019/02/01 01:08:20.282]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:495:21: note: candidate function not viable: no known conversion from 'const long' to 'mongo::StringData' for 2nd argument
       [2019/02/01 01:08:20.282]     BSONObjBuilder& append(StringData fieldName, StringData str) {
       [2019/02/01 01:08:20.282]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:511:21: note: candidate function not viable: no known conversion from 'const long' to 'const mongo::BSONSymbol' for 2nd argument
       [2019/02/01 01:08:20.282]     BSONObjBuilder& append(StringData fieldName, const BSONSymbol& symbol) {
       [2019/02/01 01:08:20.282]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:559:21: note: candidate function not viable: no known conversion from 'const long' to 'const mongo::BSONDBRef' for 2nd argument
       [2019/02/01 01:08:20.282]     BSONObjBuilder& append(StringData fieldName, const BSONDBRef& dbref) {
       [2019/02/01 01:08:20.282]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:582:21: note: candidate function not viable: no known conversion from 'const long' to 'const mongo::BSONBinData' for 2nd argument
       [2019/02/01 01:08:20.282]     BSONObjBuilder& append(StringData fieldName, const BSONBinData& bd) {
       [2019/02/01 01:08:20.282]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:615:21: note: candidate function not viable: no known conversion from 'const long' to 'const mongo::BSONCodeWScope' for 2nd argument
       [2019/02/01 01:08:20.282]     BSONObjBuilder& append(StringData fieldName, const BSONCodeWScope& cws) {
       [2019/02/01 01:08:20.282]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:1060:40: note: candidate function not viable: no known conversion from 'const long' to 'mongo::Timestamp' for 2nd argument
       [2019/02/01 01:08:20.282] inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, Timestamp optime) {
       [2019/02/01 01:08:20.282]                                        ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:324:21: note: candidate template ignored: requirement 'std::is_same<long, int64_t>::value' was not satisfied [with Int64_t = long]
       [2019/02/01 01:08:20.282]     BSONObjBuilder& append(StringData fieldName, Int64_t n) {
       [2019/02/01 01:08:20.282]                     ^
       [2019/02/01 01:08:20.282] src/mongo/bson/bsonobjbuilder.h:956:40: note: candidate template ignored: could not match 'vector<type-parameter-0-0, allocator<type-parameter-0-0> >' against 'const long'
       [2019/02/01 01:08:20.283] inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, const std::vector<T>& vals) {
       [2019/02/01 01:08:20.283]                                        ^
       [2019/02/01 01:08:20.283] src/mongo/bson/bsonobjbuilder.h:974:40: note: candidate template ignored: could not match 'list<type-parameter-0-0, allocator<type-parameter-0-0> >' against 'const long'
       [2019/02/01 01:08:20.283] inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, const std::list<T>& vals) {
       [2019/02/01 01:08:20.283]                                        ^
       [2019/02/01 01:08:20.283] src/mongo/bson/bsonobjbuilder.h:979:40: note: candidate template ignored: could not match 'set<type-parameter-0-0, less<type-parameter-0-0>, allocator<type-parameter-0-0> >' against 'const long'
       [2019/02/01 01:08:20.283] inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, const std::set<T>& vals) {
       [2019/02/01 01:08:20.283]                                        ^
       [2019/02/01 01:08:20.283] src/mongo/bson/bsonobjbuilder.h:984:40: note: candidate template ignored: could not match 'map<type-parameter-0-0, type-parameter-0-1, less<type-parameter-0-0>, allocator<pair<const type-parameter-0-0, type-parameter-0-1> > >' against 'const long'
       [2019/02/01 01:08:20.283] inline BSONObjBuilder& BSONObjBuilder::append(StringData fieldName, const std::map<K, T>& vals) {
       [2019/02/01 01:08:20.283]                                        ^
       [2019/02/01 01:08:20.283] src/mongo/bson/bsonobjbuilder.h:194:21: note: candidate function not viable: requires single argument 'e', but 2 arguments were provided
       [2019/02/01 01:08:20.283]     BSONObjBuilder& append(const BSONElement& e) {
       [2019/02/01 01:08:20.283]                     ^
       [2019/02/01 01:08:20.283] src/mongo/bson/bsonobjbuilder.h:483:21: note: candidate function not viable: requires 3 arguments, but 2 were provided
       [2019/02/01 01:08:20.283]     BSONObjBuilder& append(StringData fieldName, const char* str, int sz) {
       [2019/02/01 01:08:20.283]                     ^
       [2019/02/01 01:08:20.699] 1 error generated.
      

            Assignee:
            andrew.morrow@mongodb.com Andrew Morrow (Inactive)
            Reporter:
            louis.williams@mongodb.com Louis Williams
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: