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
core/swap.hpp(81,1): fatal error C1202: recursive type or function dependency context too complex #148
Comments
Hi @Lastique |
Not at the moment or in the coming few weeks. If you are willing to try something, you could try the following:
|
Reduced example:
Fails under all compilers (e.g. https://godbolt.org/z/ea65PWz9b). The reason is that |
Why did we need the change in 8a8738a? |
On July 9, 2023 8:28:34 PM Peter Dimov ***@***.***> wrote:
Why did we need the change in
8a8738a?
This reflects std::swap. I also needed this in some of my code.
Transparently noexcept swap is the right thing to do. The fix should be to
prevent boost::swap from being found by ADL.
|
To prevent |
This code is incorrect either way. If I'm not sure this repro is equivalent to the code posted by the OP. Their code involves |
… ADL. This resolves infinite recursion when boost::swap is called on types that are defined in namespace boost. The swap_impl implementation and noexcept specification is using an unqualified call to swap, so if the argument types are defined in namespace boost then our boost::swap function may be found and selected to resolve the call. Fixes #148.
Not necessarily, a using directive would do. |
My guess is that it uses
I don't think it would. |
… ADL. This resolves infinite recursion when boost::swap is called on types that are defined in namespace boost. The swap_impl implementation and noexcept specification is using an unqualified call to swap, so if the argument types are defined in namespace boost then our boost::swap function may be found and selected to resolve the call. Fixes #148.
… ADL. This resolves infinite recursion when boost::swap is called on types that are defined in namespace boost. The swap_impl implementation and noexcept specification is using an unqualified call to swap, so if the argument types are defined in namespace boost then our boost::swap function may be found and selected to resolve the call. Fixes #148.
It does work in my local testing, but it turns out it has unexpected side effect that shows as I don't see a way around this. Would we be willing to ban |
I don't think we can do that. Types defined in namespace |
The idea was to move those types to their own namespaces within Another solution would be to rename |
We can add
|
The rename allows to avoid forming an infinite recursion in compile time (because of noexcept specification that needs to resolve the unqualified call to swap) or run time (in case if the boost::swap function is the only one suitable for the passed arguments). To avoid the compile-time recursion, removed noexcept specification from boost::swap. The specification is still present in boost::core::invoke_swap. Deprecated boost::swap and associated headers. boost::core::invoke_swap is defined in a new boost/core/invoke_swap.hpp header. Updated docs and tests. Removed tests that check inclusion of deprecated headers. Fixes #148.
The rename allows to avoid forming an infinite recursion in compile time (because of noexcept specification that needs to resolve the unqualified call to swap) or run time (in case if the boost::swap function is the only one suitable for the passed arguments). To avoid the compile-time recursion, removed noexcept specification from boost::swap. The specification is still present in boost::core::invoke_swap. Deprecated boost::swap and associated headers. boost::core::invoke_swap is defined in a new boost/core/invoke_swap.hpp header. Updated docs and tests. Removed tests that check inclusion of deprecated headers. Fixes #148.
We get a
boost_1_82_0\boost/core/swap.hpp(81,1): fatal error C1202: recursive type or function dependency context too complex
when compiling this program with VC2019 or VC2022 and stdc++17 enabled. linkNeither g++ nor clang have a problem.
The code is nonsensical and we only boiled down the real code to make it a minimal example. Also
#include <boost/swap.hpp>
is not used but only needed for getting the error.Maybe this is more a VC++ issue than a boost issue.
The text was updated successfully, but these errors were encountered: