[SERVER-82983] Fix ambiguity formatting DecimalCounter using libfmt in bsonelement.cpp Created: 08/Nov/23  Updated: 29/Nov/23  Resolved: 09/Nov/23

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: 7.3.0-rc0, 7.2.0-rc2

Type: Task Priority: Major - P3
Reporter: Henrik Edin Assignee: Henrik Edin
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backports
Problem/Incident
is caused by SERVER-81191 Checking array field names in IDL is ... Closed
Backwards Compatibility: Fully Compatible
Backport Requested:
v7.2
Sprint: Execution Team 2023-11-13
Participants:

 Description   

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);



 Comments   
Comment by Githook User [ 28/Nov/23 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-82983 Fix compiler ambiguity with formatting DecimalCounter using libfmt

(cherry picked from commit c25d33c42c6195cc11bf93035b40ad7da4384c30)
Branch: v7.2
https://github.com/mongodb/mongo/commit/931f33952a8f886b219de755e8bda7f7316fa638

Comment by Githook User [ 09/Nov/23 ]

Author:

{'name': 'Henrik Edin', 'email': 'henrik.edin@mongodb.com', 'username': 'henrikedin'}

Message: SERVER-82983 Fix compiler ambiguity with formatting DecimalCounter using libfmt
Branch: master
https://github.com/mongodb/mongo/commit/c25d33c42c6195cc11bf93035b40ad7da4384c30

Generated at Thu Feb 08 06:50:55 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.