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

Fix ambiguity formatting DecimalCounter using libfmt in bsonelement.cpp

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.3.0-rc0, 7.2.0-rc2
    • Affects Version/s: None
    • Component/s: None
    • None
    • Fully Compatible
    • v7.2
    • Execution Team 2023-11-13

      Visual Studio 2022 17.5.4 outputs the following error:

      D:\mongo\src\third_party\fmt\dist\include\fmt\ostream.h(114,3): error C2593: 'operator <<' is ambiguous
        output << value;
        ^
      C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.35.32215\include\ostream(298,39): note: could be 'std::basic_ostream<char,std::char_traits<char>> &std::basic_ostream<char,std::char_traits<char>>::operator <<(unsigned int)'
          basic_ostream& __CLR_OR_THIS_CALL operator<<(unsigned int _Val) { // insert an unsigned int
                                            ^
      D:\mongo\src\mongo/base/string_data.h(216,15): note: or       'std::ostream &mongo::operator <<(std::ostream &,mongo::StringData)' [found using argument-dependent lookup]
      std::ostream& operator<<(std::ostream& stream, StringData value);
                    ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\ostream.h(114,3): note: while trying to match the argument list '(std::basic_ostream<char,std::char_traits<char>>, const T)'
              with
              [
                  T=mongo::DecimalCounter<uint32_t>
              ]
        output << value;
        ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\ostream.h(138,1): note: see reference to function template instantiation 'void fmt::v7::detail::format_value<T,mongo::DecimalCounter<uint32_t>>(fmt::v7::detail::buffer<T> &,const mongo::DecimalCounter<uint32_t> &,fmt::v7::detail::locale_ref)' being compiled
              with
              [
                  T=char
              ]
          format_value(buffer, value, ctx.locale());
      ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1117,1): note: see reference to function template instantiation 'OutputIt fmt::v7::detail::fallback_formatter<mongo::DecimalCounter<uint32_t>,Char,void>::format<fmt::v7::detail::buffer_appender<char>>(const T &,fmt::v7::basic_format_context<OutputIt,Char> &)' being compiled
              with
              [
                  OutputIt=fmt::v7::detail::buffer_appender<char>,
                  Char=char,
                  T=mongo::DecimalCounter<uint32_t>
              ]
          ctx.advance_to(f.format(*static_cast<const T*>(arg), ctx));
      ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1117,19): note: see reference to function template instantiation 'OutputIt fmt::v7::detail::fallback_formatter<mongo::DecimalCounter<uint32_t>,Char,void>::format<fmt::v7::detail::buffer_appender<char>>(const T &,fmt::v7::basic_format_context<OutputIt,Char> &)' being compiled
              with
              [
                  OutputIt=fmt::v7::detail::buffer_appender<char>,
                  Char=char,
                  T=mongo::DecimalCounter<uint32_t>
              ]
          ctx.advance_to(f.format(*static_cast<const T*>(arg), ctx));
                        ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1106): note: see reference to function template instantiation 'void fmt::v7::detail::value<Context>::format_custom_arg<T,fmt::v7::detail::fallback_formatter<T,Char,void>>(const void *,fmt::v7::basic_format_parse_context<Char,fmt::v7::detail::error_handler> &,Context &)' being compiled
              with
              [
                  Context=fmt::v7::format_context,
                  T=mongo::DecimalCounter<uint32_t>,
                  Char=char
              ]
                               fallback_formatter<T, char_type>>>;
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1103,19): note: see reference to function template instantiation 'void fmt::v7::detail::value<Context>::format_custom_arg<T,fmt::v7::detail::fallback_formatter<T,Char,void>>(const void *,fmt::v7::basic_format_parse_context<Char,fmt::v7::detail::error_handler> &,Context &)' being compiled
              with
              [
                  Context=fmt::v7::format_context,
                  T=mongo::DecimalCounter<uint32_t>,
                  Char=char
              ]
          custom.format = format_custom_arg<
                        ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1445,3): note: see reference to function template instantiation 'fmt::v7::detail::value<Context>::value<U>(const T &)' being compiled
              with
              [
                  Context=fmt::v7::format_context,
                  U=mongo::DecimalCounter<uint32_t>,
                  T=mongo::DecimalCounter<uint32_t>
              ]
        return check<T>(arg_mapper<Context>().map(val));
        ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1445,3): note: see reference to function template instantiation 'fmt::v7::detail::value<Context>::value<U>(const T &)' being compiled
              with
              [
                  Context=fmt::v7::format_context,
                  U=mongo::DecimalCounter<uint32_t>,
                  T=mongo::DecimalCounter<uint32_t>
              ]
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1589): note: see reference to function template instantiation 'fmt::v7::detail::value<Context> fmt::v7::detail::make_arg<true,Context,fmt::v7::detail::type::custom_type,mongo::DecimalCounter<uint32_t>,0>(const T &)' being compiled
              with
              [
                  Context=fmt::v7::format_context,
                  T=mongo::DecimalCounter<uint32_t>
              ]
        format_arg_store(const Args&... args)
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1589,1): note: while compiling class template member function 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<char>,char>,mongo::StringData,mongo::DecimalCounter<uint32_t>>::format_arg_store(const mongo::StringData &,const mongo::DecimalCounter<uint32_t> &)'
        format_arg_store(const Args&... args)
      ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(1633,3): note: see reference to function template instantiation 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<char>,char>,mongo::StringData,mongo::DecimalCounter<uint32_t>>::format_arg_store(const mongo::StringData &,const mongo::DecimalCounter<uint32_t> &)' being compiled
        return {args...};
        ^
      D:\mongo\src\third_party\fmt\dist\include\fmt\core.h(2081): note: see reference to class template instantiation 'fmt::v7::format_arg_store<fmt::v7::basic_format_context<fmt::v7::detail::buffer_appender<char>,char>,mongo::StringData,mongo::DecimalCounter<uint32_t>>' being compiled
      FMT_INLINE std::basic_string<Char> format(const S& format_str, Args&&... args) {
      src\mongo\bson\bsonelement.cpp(452): note: see reference to function template instantiation 'std::basic_string<char,std::char_traits<char>,std::allocator<char>> fmt::v7::format<char[52],mongo::StringData&,mongo::DecimalCounter<uint32_t>&,char>(const S (&),mongo::StringData &,mongo::DecimalCounter<uint32_t> &)' being compiled
              with
              [
                  S=char [52]
              ]
                      fieldName == counter);
      

            Assignee:
            henrik.edin@mongodb.com Henrik Edin
            Reporter:
            henrik.edin@mongodb.com Henrik Edin
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: