BSONObjBuilder does not handle uint64_t correctly (overloaded append() are ambiguous)

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Won't Fix
    • Priority: Critical - P2
    • None
    • Affects Version/s: None
    • Component/s: Internal Client
    • None
    • Environment:
      Ubuntu Lucid 64bit, GCC 4.3.4/4.4.3
    • Major Change
    • Linux
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The following code does not compile due to ambiguous BSONObjBuilder::append() overload

      code:
      uint64_t orz = 10;
      BSONObj o = BSON("test" << orz);

      gcc compile error messages:

      /usr/include/mongo/client/../db/jsobj.h:1924: error: call of overloaded 'append(const char*&, long unsigned int&)' is ambiguous
      /usr/include/mongo/client/../db/jsobj.h:1208: note: candidates are: void mongo::BSONObjBuilder::append(const char*, mongo::BSONObj) <near match>
      /usr/include/mongo/client/../db/jsobj.h:1214: note: void mongo::BSONObjBuilder::append(const std::string&, mongo::BSONObj) <near match>
      /usr/include/mongo/client/../db/jsobj.h:1253: note: void mongo::BSONObjBuilder::append(const char*, bool)
      /usr/include/mongo/client/../db/jsobj.h:1260: note: void mongo::BSONObjBuilder::append(const char*, int)
      /usr/include/mongo/client/../db/jsobj.h:1266: note: void mongo::BSONObjBuilder::append(const std::string&, int)
      /usr/include/mongo/client/../db/jsobj.h:1271: note: void mongo::BSONObjBuilder::append(const char*, unsigned int)
      /usr/include/mongo/client/../db/jsobj.h:1274: note: void mongo::BSONObjBuilder::append(const char*, long long int)
      /usr/include/mongo/client/../db/jsobj.h:1281: note: void mongo::BSONObjBuilder::append(const std::string&, long long int)
      /usr/include/mongo/client/../db/jsobj.h:1322: note: mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const char*, double)
      /usr/include/mongo/client/../db/jsobj.h:1370: note: void mongo::BSONObjBuilder::append(const char*, mongo::Date_t)
      /usr/include/mongo/client/../db/jsobj.h:1398: note: mongo::BSONObjBuilder& mongo::BSONObjBuilder::append(const char*, const char*) <near match>
      /usr/include/mongo/client/../db/jsobj.h:1406: note: void mongo::BSONObjBuilder::append(const char*, std::string) <near match>

      Apparently the problem is that BSONObjBuilder::append() does not overload specifically for "unsigned long long" type so for uint64_t it's possible to match all types, leading to ambiguous overload.

      This bug is in all release, including the trunk version.

            Assignee:
            Eliot Horowitz (Inactive)
            Reporter:
            Mark Sung
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: