Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MSVC][c++latest] error C2668: 'std::format_to': ambiguous call to overloaded function #3377

Closed
Zhaojun-Liu opened this issue Apr 10, 2023 · 4 comments

Comments

@Zhaojun-Liu
Copy link
Contributor

Hi all,
I tried to build Fmt with VS2022 on Windows, but it failed due to error C2668. Could anyone look at this issue? Thanks in advance.

Environment:
VS2022 + Windows Server

Repro steps:

  1. Open a VS 2022 x64 Native Tools command.
  2. git clone https://github.com/fmtlib/fmt F:\gitP\fmtlib\fmt
  3. git -C "F:\gitP\fmtlib\fmt" reset --hard 4a4a2a2
  4. set CL= /std:c++latest
  5. mkdir F:\gitP\fmtlib\fmt\build_amd64 and cd F:\gitP\fmtlib\fmt\build_amd64
  6. cmake -G "Visual Studio 17 2022" -A x64 -DCMAKE_SYSTEM_VERSION=10.0.22621.0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_STANDARD=20 ..
  7. cmake --build . --config Release --verbose -- /maxcpucount

Expected result:
Build successfully.

Actual result:

"F:\gitP\fmtlib\fmt\build_amd64\ALL_BUILD.vcxproj" (default target) (1) ->
       "F:\gitP\fmtlib\fmt\build_amd64\test\format-impl-test.vcxproj" (default target) (19) ->
       (ClCompile target) -> 
         F:\gitP\fmtlib\fmt\test\format-impl-test.cc(304,5): error C2668: 'fmt::v9::format_to': ambiguous call to overloaded function [F:\gitP\fmtlib\fmt\build_amd64\test\format-impl-test.vcxproj]


       "F:\gitP\fmtlib\fmt\build_amd64\ALL_BUILD.vcxproj" (default target) (1) ->
       "F:\gitP\fmtlib\fmt\build_amd64\test\args-test.vcxproj" (default target) (3) ->
         F:\gitP\fmtlib\fmt\test\args-test.cc(47,12): error C2668: 'std::format_to': ambiguous call to overloaded function [F:\gitP\fmtlib\fmt\build_amd64\test\args-test.vcxproj]


       "F:\gitP\fmtlib\fmt\build_amd64\ALL_BUILD.vcxproj" (default target) (1) ->
       "F:\gitP\fmtlib\fmt\build_amd64\test\format-test.vcxproj" (default target) (18) ->
         F:\gitP\fmtlib\fmt\test\format-test.cc(1642,12): error C2668: 'std::format_to': ambiguous call to overloaded function [F:\gitP\fmtlib\fmt\build_amd64\test\format-test.vcxproj]
         F:\gitP\fmtlib\fmt\test\format-test.cc(1664,12): error C2668: 'std::format_to': ambiguous call to overloaded function [F:\gitP\fmtlib\fmt\build_amd64\test\format-test.vcxproj]
         F:\gitP\fmtlib\fmt\test\format-test.cc(1685,5): error C2668: 'std::format_to': ambiguous call to overloaded function [F:\gitP\fmtlib\fmt\build_amd64\test\format-test.vcxproj]
         F:\gitP\fmtlib\fmt\test\format-test.cc(1726,3): error C2668: 'std::format_to': ambiguous call to overloaded function [F:\gitP\fmtlib\fmt\build_amd64\test\format-test.vcxproj]
         F:\gitP\fmtlib\fmt\test\format-test.cc(1864,3): error C2668: 'std::format_to': ambiguous call to overloaded function [F:\gitP\fmtlib\fmt\build_amd64\test\format-test.vcxproj]

    23 Warning(s)
    7 Error(s)

More:
I tried to use namespace to qualify the call to format_to, i.e. change it to fmt::format_to, it will build ok.

Detailed log:
build.log

@vitaut
Copy link
Contributor

vitaut commented Apr 10, 2023

Microsoft "STL" probably pulls in <format> for no good reason causing ambiguities. A PR to qualify problematic calls would be welcome.

@Zhaojun-Liu
Copy link
Contributor Author

Microsoft "STL" probably pulls in <format> for no good reason causing ambiguities. A PR to qualify problematic calls would be welcome.

Hi @vitaut, I made a PR #3378 to fix this issue, could you please help review and approval it? Thanks.

@vitaut vitaut closed this as completed Apr 11, 2023
@bebuch
Copy link

bebuch commented May 8, 2023

Today I encountered the same problem with MSVC and LLVM on Windows. Can you please create a new release? I am only allowed to use releases and this makes it impossible to use the latest version.

@vitaut
Copy link
Contributor

vitaut commented May 8, 2023

We don't make releases on request but the work on the new one has already begun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants