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

VS2017 noexcept-in-typesystem bug is hitting with the definition of 'unique_private_namespace' #302

Closed
iamtcby5188 opened this issue Feb 17, 2023 · 9 comments · Fixed by #316
Labels
compiler-support msvc Bugs or behavioral issues that are specific to MSVC

Comments

@iamtcby5188
Copy link

1>wb2.cpp
1>e:\code\mytest\wb2\packages\microsoft.windows.implementationlibrary.1.0.230202.1\include\wil\resource.h(2550): error C2440: “specialization”: 无法从“void (__stdcall *)(HANDLE) noexcept”转换为“unknown-type”
1>e:\code\mytest\wb2\packages\microsoft.windows.implementationlibrary.1.0.230202.1\include\wil\resource.h(2550): note: 上下文不允许消除重载函数的歧义

@dunhor
Copy link
Member

dunhor commented Feb 17, 2023

What does your code look like that causes this error?

@dunhor dunhor added the info-needed More information is needed label Feb 17, 2023
@dunhor
Copy link
Member

dunhor commented Feb 17, 2023

Also, since this appears to maybe be related to noexcept in the type system, what compiler/version are you using and what C++ version are you compiling against?

@jimmyleocn
Copy link

jimmyleocn commented Mar 23, 2023

Same error here.
Target System: Windows 10
SDK: 10.0.17763.0
ToolChain: Visual Studio 2017(v141)
C++17
Is there any stable version older for download? Thx.

@dunhor
Copy link
Member

dunhor commented Mar 23, 2023

If memory serves me correctly, VS2017 has a behavior where it'll ignore noexcept declared on a function pointer, but not ignore it in decltype (or the other way around; it's been a while). If you compile with /std:c++17, does the error persist?

@dunhor
Copy link
Member

dunhor commented Mar 23, 2023

If that is the issue, then we could go about it by explicitly writing the type instead of using decltype as we've done in the past before.

    template <ULONG flags = 0>
    using unique_private_namespace = unique_any_handle_null_only<void(__stdcall*)(HANDLE) WI_PFN_NOEXCEPT, &details::ClosePrivateNamespaceHelper<flags>>;

@icnocop
Copy link

icnocop commented Mar 24, 2023

See #25 and #272

@icnocop
Copy link

icnocop commented Mar 24, 2023

If you compile with /std:c++17, does the error persist?

In my case, compiling with /std:c++17 did not resolve the issue.

Windows SDK Version: 10.0.14393.0
Platform Toolset: Visual Studio 2017 (v141)
Configuration Type: Application (.exe)
Use of MFC: Use MFC in a Shared DLL
Character Set: Use Unicode Character Set

Microsoft.Windows.ImplementationLibrary 1.0.230202.1
Microsoft.Web.WebView2 1.0.1661.34

.\packages\microsoft.windows.implementationlibrary.1.0.230202.1\include\wil\resource.h(2550): error C2440: 'specialization': cannot convert from 'void (__cdecl *)(HANDLE) noexcept' to 'unknown-type'
.\packages\microsoft.windows.implementationlibrary.1.0.230202.1\include\wil\resource.h(2550): note: Context does not allow for disambiguation of overloaded function

@dunhor
Copy link
Member

dunhor commented Mar 24, 2023

Sounds like from my comment in #25, it was VS 2019 that had the noexcept pointer-to-function issue, not 2017. Perhaps 2017 is just even more broken... Can anyone hitting this check to see if the code I pasted above helps or not?

@icnocop
Copy link

icnocop commented Mar 24, 2023

Yes, replacing

    template <ULONG flags = 0>
    using unique_private_namespace = unique_any_handle_null_only<decltype(details::ClosePrivateNamespaceHelper<flags>), &details::ClosePrivateNamespaceHelper<flags>>;

with

template <ULONG flags = 0>
    using unique_private_namespace = unique_any_handle_null_only<void(__stdcall*)(HANDLE) WI_PFN_NOEXCEPT, &details::ClosePrivateNamespaceHelper<flags>>;

allows the code to compile.

As another work-around, downgrade the NuGet package Microsoft.Windows.ImplementationLibrary to 1.0.210803.1.

Thank you.

@dunhor dunhor added msvc Bugs or behavioral issues that are specific to MSVC compiler-support and removed info-needed More information is needed labels Mar 24, 2023
@dunhor dunhor changed the title 编译报错 VS2017 noexcept-in-typesystem bug is hitting with the definition of 'unique_private_namespace' Apr 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler-support msvc Bugs or behavioral issues that are specific to MSVC
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants