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][permissive-] ranges.h(395,41): error C2672: 'get': no matching overloaded function found #2401

Closed
QuellaZhang opened this issue Jun 29, 2021 · 4 comments · Fixed by #2407

Comments

@QuellaZhang
Copy link

Hi vitaut,

Tried to build fmt with /permissive- on MSVC and found the follow error, can you help look? Thanks!

Repro steps:

  1. open VS2019 x86 tools command (VS2019 16.10.2)
  2. git clone https://github.com/fmtlib/fmt
  3. cd fmt
  4. mkdir build && cd build
  5. set CL=/permissive-
  6. cmake -G "Visual Studio 16 2019" -DCMAKE_BUILD_TYPE=Release -A Win32 ..
  7. cmake --build . --config Release --verbose -- /maxcpucount

Repro command line:
"C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.29.30037\bin\HostX64\x86\CL.exe" /c /IE:\fmt\include /IE:\fmt\test\gtest. /nologo /W1 /WX- /diagnostics:column /O2 /Ob2 /Oy- /D WIN32 /D _WINDOWS /D NDEBUG /D GTEST_HAS_STD_WSTRING=1 /D _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING=1 /D FMT_LOCALE /D "CMAKE_INTDIR="Release"" /D _MBCS /Gm- /EHsc /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /GR /external:env:EXTERNAL_INCLUDE /external:W1 /Gd /TP /analyze- /errorReport:queue "E:\fmt\test\ranges-test.cc" /permissive-

build.log
Error info:
F:\gitP\fmtlib\fmt.git\include\fmt/ranges.h(395,41): error C2672: 'get': no matching overloaded function found [F:\gitP\fmtlib\fmt.git\build_x86\test\ranges-test.vcxproj]
F:\gitP\fmtlib\fmt.git\include\fmt/ranges.h(394,1): error C2784: 'tuple_element<_Idx,std::pair<_Ty1,_Ty2>>::type &std::get(std::pair<_Ty1,_Ty2> &) noexcept': could not deduce template argument for 'std::pair<_Ty1,_Ty2> &' from 'const std::tuple' [F:\gitP\fmtlib\fmt.git\build_x86\test\ranges-test.vcxproj]
F:\gitP\fmtlib\fmt.git\include\fmt/ranges.h(394,1): error C2784: 'tuple_element<_Idx,std::pair<_Ty1,_Ty2>>::type &std::get(std::pair<_Ty1,_Ty2> &) noexcept': could not deduce template argument for 'std::pair<_Ty1,_Ty2> &' from 'const std::tuple<char,int &>' [F:\gitP\fmtlib\fmt.git\build_x86\test\ranges-test.vcxproj]
F:\gitP\fmtlib\fmt.git\include\fmt/ranges.h(394,1): error C2784: 'tuple_element<_Idx,std::pair<_Ty1,_Ty2>>::type &std::get(std::pair<_Ty1,_Ty2> &) noexcept': could not deduce template argument for 'std::pair<_Ty1,_Ty2> &' from 'const std::tuple<char,int,float>' [F:\gitP\fmtlib\fmt.git\build_x86\test\ranges-test.vcxproj]

@vitaut
Copy link
Contributor

vitaut commented Jun 29, 2021

I don't have a Windows machine at hand to investigate this but a PR with a workaround would be welcome.

@QuellaZhang
Copy link
Author

@vitaut Thanks, I can help with testing. And you say "workaround", do you think this is a complier issue? If so, I will confirm with them.

@vitaut
Copy link
Contributor

vitaut commented Jul 1, 2021

do you think this is a complier issue?

I am not sure but since it only happens on MSVC and specific configuration it's quite likely.

joemmett added a commit to joemmett/fmt that referenced this issue Jul 1, 2021
ranges.h needs std::get overloads from <tuple> but does not directly
include it. This causes compilation failures in MSVC with /permissive-.
On other platforms <tuple> is included as a dependency from other headers
(specifically from <memory>), but there is no such implicit dependency in
MSVC's STL.

Fixes fmtlib#2401
@joemmett
Copy link
Contributor

joemmett commented Jul 1, 2021

This is due to differences in implicit dependencies in the standard template libraries. ranges.h needs <tuple> and gets it on other platforms from <memory>, but MSVC's STL doesn't have that implicit dependency. I have submitted a PR #2407 to add an explicit include of <tuple> to avoid relying on STL internals.

joemmett added a commit to joemmett/fmt that referenced this issue Jul 1, 2021
This replaces the `std::get` call with an unqualified equivalent to allow
it to be treated as a dependent call.

ranges.h needs std::get overloads from `<tuple>` but does not directly
include it. This causes compilation failures in MSVC with /permissive-.
On other platforms `<tuple>` is included as a dependency from other headers
(specifically from `<memory>`), but there is no such implicit dependency in
MSVC's STL.

Fixes fmtlib#2401
vitaut pushed a commit that referenced this issue Jul 1, 2021
This replaces the `std::get` call with an unqualified equivalent to allow
it to be treated as a dependent call.

ranges.h needs std::get overloads from `<tuple>` but does not directly
include it. This causes compilation failures in MSVC with /permissive-.
On other platforms `<tuple>` is included as a dependency from other headers
(specifically from `<memory>`), but there is no such implicit dependency in
MSVC's STL.

Fixes #2401
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

Successfully merging a pull request may close this issue.

3 participants