-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Compilation Error with MSVC (14.43.34808) with -std:c++latest #4391
Conversation
Fixes the following error with MSVC ``` d:\vcpkg\installed\arm64-msvc-static-md\include\fmt\base.h(2302): error C2446: ':': no conversion from 'std::tuple<T1,T2>' to 'unsigned __int64' with [ T1=fmt::v11::detail::<unnamed-enum-is_unpacked_bit>, T2=size_t ] d:\vcpkg\installed\arm64-msvc-static-md\include\fmt\base.h(2302): note: the template instantiation context (the oldest one first) is D:\optimlir\proto\CodeTemplates.h(103): note: see reference to function template instantiation 'std::string fmt::v11::format<fmt::v11::join_view<std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,char>>(fmt::v11::fstring<fmt::v11::join_view<std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,char>>,fmt::v11::join_view<std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,std::_Vector_const_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,char> &&)' being compiled with [ _Ty=std::string ] ```
This looks like a compiler bug since there is no |
@vitaut https://learn.microsoft.com/en-us/cpp/error-messages/compiler-warnings/c5054?view=msvc-170 The cast is to make sure the enum is explicitly casted to underlying type so its not using the deprecated implicit casting |
Likely need more information like what the code looks like that's instantiating the fmt templates. Just messing around with the enum idea on godbolt [0] suggests that it only applies when using an operator with two different enums, not between an enum and a size_t, as is the case here. That goes along with your paper link as that describes enum/enum or enum/float operations as being deprecated, but not enum/int. clang 20 appears to agree with the latest version of MSVC on godbolt with how these enums are interacting with operators. |
@dinomight you compiled with c++20. This is only deprecated in c++20 You code fails to compile with c++26
|
Correct, but the warnings were still generated under C++20 for both compilers (line 8). My point was that the enum/int combination (line 7) is not a warning and that's the one that mirrors the enum/size_t in this PR and has me wondering how you are instantiating the fmt templates. And just to be clear, without a reproducible test case, it's unlikely this change will get merged as it doesn't look necessary at this time, as vitaut has already pointed out. |
Thanks sorry I missed that earlier (line 7 is being successfully compiled) |
Yes and that's what I was suggesting to report. |
Fixes the following error with MSVC